Web 前端学习之盒子模型

1. 定义盒子外型

		<style?
			.bios {
			/* 指定宽度(width)跟高度(height) */
			width: 300px;
			height: 300px;
			/* 指定背景颜色 */
			background-color: rgb(234,143,23);
			/* 指定内边距 (有放大的效果)*/
			/* padding: 100px; */
			/* 指定边框 */
			border: 100px solid #f0f;
			/* 指定外边框 */
			margin: 100px;
			/* 浮动:让块元素在一行显示 */
			float: left;
			}
			.bio {
				width: 100px;
				height: 100px;
				background-color: #ff0;
				padding: 100px;
				border: 100px solid #00f;
				margin: 100px;
				float: left;
			}
		</style>

2. 给定内容

<div class="bios">309030803070</div>
<div class="bio">309030803070</div>

3. 完整代码如下

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>	
			.bios {
				/* 指定宽度(width)跟高度(height) */
			width: 300px;
			height: 300px;
			/* 指定背景颜色 */
			background-color: rgb(234,143,23);
			/* 指定内边距 (有放大的效果)*/
			/* padding: 100px; */
			/* 指定边框 */
			border: 100px solid #f0f;
			/* 指定外边框 */
			margin: 100px;
			/* 浮动:让块元素在一行显示 */
			float: left;
			}
			.bio {
				width: 100px;
				height: 100px;
				background-color: #ff0;
				padding: 100px;
				border: 100px solid #00f;
				margin: 100px;
				float: left;
			}
		</style>
		
	</head>
	<body>
		<!-- 盒子模型 -->
		<!-- 内容(width+heigh) -->
		<!-- 背景生效区域 内边距+(width+height) -->
		<!-- 从内到外分别是 内容(width+height)——内边距——边框——外边框 -->
		<div class="bios">309030803070</div>
		<div class="bio">309030803070</div>
		<!-- 盒子总宽度 -->
		<!-- 左外边距+上边框+下边框+width+右内边距+右边框+右外边距 -->
		<!-- 和总高度 -->
		<!-- 上外编剧+上边框+上内边距+height+下内边距+下边框+下外边距 -->
		
		<!-- 去掉内边距 	width+2*内边距 	height+2*内边距 -->
		<!-- 去掉边框 	width+2*边框		height+2*边框 -->
		<!-- 去掉外边框	width+2*外边距	height+2*外边距 -->
	</body>
</html>

执行结果如下所示:
2021-9-27
右边的就是盒子;

结束语

若这篇文章有帮到你,给个赞,收个藏,欢迎大家留言评论;
若文章有什么错误,欢迎大家指教。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值