css绘制三角形以及梯形

等腰三角形

<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
 <style type="text/css">
 	#box{
    
    
		width: 0;
		height: 0;
		border-top: 40px solid transparent;
		border-left: 40px solid transparent;
		border-right: 40px solid transparent;
		border-bottom: 40px solid red;
	}
 </style>
<body>
	<div id="box">
		
	</div>
</body>
 
</html>

直角三角形

<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
 <style type="text/css">
 	#box{
    
    
		width: 0px;
		height: 0;
		border-top: 0px solid transparent;
		border-left: 0px solid transparent;
		border-right: 100px solid transparent;
		border-bottom: 40px solid red;
		
	}
 </style>
<body>
	<div id="box">
		
	</div>
</body>
 
</html>

梯形

<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
 <style type="text/css">
 	#box{
    
    
		width: 50px;
		height: 0;
		border-top: 40px solid transparent;
		border-left: 40px solid transparent;
		border-right: 40px solid transparent;
		border-bottom: 40px solid red;
	}
 </style>
<body>
	<div id="box">
		
	</div>
</body>
 
</html>

单边梯形

<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
 <style type="text/css">
 	#box{
    
    
		width: 50px;
		height: 0;
		border-top: 40px solid transparent;
		border-left: 40px solid transparent;
		border-right: 40px solid transparent;
		border-bottom: 40px solid red;
	}
 </style>
<body>
	<div id="box">
		
	</div>
</body>
 
</html>

猜你喜欢

转载自blog.csdn.net/qq_47272950/article/details/124465279