盒模型之border实践--三角形

本文介绍了如何使用CSS的基本属性来实现各种有趣的图形效果,包括简单的蓝色正方形盒子、三角形及一个由多个元素组合而成的圣诞树图形。通过巧妙地设置边界样式、宽度、颜色等属性,可以不借助额外图片资源实现这些效果。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
<style type="text/css">
	div{
		width: 300px;
		height: 300px;
		background: blue;
		border: 50px dotted green;
		/*单独设置某个方向的边框*/
		border-top: 10px solid orange;
		/*也可以单独设置边框的三要素之一,如形色*/
		border-style: dashed;
	}
</style>
</head>
<body>
	<div>
		盒子的border 3要素 宽border-width 形状border-style 以及颜色border-color
	</div>
</body>
</html>

1.三角形

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>Document</title>
<style type="text/css">

	#trip{

		width: 0px;
		height: 0px;
		border-top: 50px solid white ;
		border-right: 50px solid white;
		border-bottom: 50px solid white;
		border-left: 50px solid orange;
	}
</style>
</head>
<body>
	
	<div id="trip"></div>

</body>
</html>

2.圣诞树

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>圣诞树</title>
<style type="text/css">

	#trip1{

		width: 0px;
		height: 0px;
		border-top: 100px solid white ;
		border-right: 100px solid white;
		border-bottom: 100px solid green;
		border-left: 100px solid white;
		float: left;
		margin-left: 100px;
	}

	#trip2{
		width: 0px;
		height: 0px;
		border-top: 200px solid white;
		border-right: 200px solid white;
		border-bottom: 200px solid green;
		border-left: 200px solid white;
	}
	#trip3{
		width: 100px;
		height: 200px;
		background: gray;
		margin-left: 150px;
	}
</style>
</head>
<body>
	
	<div id="trip1"></div>
	<div id="trip2"></div>
	<div id="trip3"></div>
</body>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mind_programmonkey

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值