前端基础-css盒子模型、定位操作(2018年8月16日)

2018年08月17日 16:23:15阅读数:672博客 / 大白鲸的博客 / HTML/CSS

作业1:

盒子模型基本元素:内容(content)、外边距(margin)、边框(border)、内边距(padding)

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>盒子模型的元素实例</title>
	<style type="text/css">
		.box{
			width: 300px;
			height: 300px;
			background-color: yellow;
			margin: 20px;
			border: 20px solid lightblue;
			border-radius: 10px;
			text-align: center;

		}
		.box a{
			line-height: 300px;
			font-size: 25px;
		}

	</style>
</head>
<body>
	<div class="box"><a href="">我是盒子模型</a>

	</div>

</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

作业2:

四种常用的定位操作实例

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>盒子模型的元素实例</title>
	<style type="text/css">
		.box{
			width: 300px;
			height: 300px;
			background-color: yellow;
			text-align: center;

		}
		.box a{
			line-height: 300px;
			font-size: 25px;
		}
		.box2{
			width: 300px;
			height: 300px;
			background-color: lightblue;
			text-align: center;
			display:table-cell;
			vertical-align: middle;

		}
	</style>
</head>
<body><h2>1.行内子元素居住设置</h2>
	<div class="box"><a href="">我是盒子模型</a>

	</div>
	<hr>
	<h2>2.多行文本子元素居住设置</h2>
	<div class="box2">
		<span>我是多行文本居住</span><br>
		<span>我是多行文本居住</span>

	</div>
	<hr>
	<h2>3.块级子元素居住设置</h2>
	<div class="box2">
		<span>我是多行文本居住</span><br>
		<span>我是多行文本居住</span>

	</div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

作业3:

css定位操作绝对定位制作十字型块级实例

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>盒子模型的相对定位实例</title>
	<style type="text/css">
		body{
			margin: 0;
		}
		.box{
			width: 600px;
			height: 600px;
			background-color: #888;
			position: absolute;

		}	
		.box1{
			width: 200px;
			height: 200px;
			background-color: lightcoral;
			position: absolute;
			left: 200px;
			top: 0px;			
		}
		.box2{
			width: 200px;
			height: 200px;
			background-color: lightgreen;
			position: absolute;
			top: 200px;
			left: 400px;
		}
		.box3{
			width: 200px;
			height: 200px;
			background-color: lightblue;
			position: absolute;
			left: 200px;
			top: 400px;		
		}
		.box4{
			width: 200px;
			height: 200px;
			background-color: lightpink;
			position: absolute;
			left: 0px;
			top: 200px;				
		}		

	</style>
</head>
<body>
	<div class="box"></div>
	<div class="box1"></div>
	<div class="box2"></div>
	<div class="box3"></div>
	<div class="box4"></div>	
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


批改状态:合格

老师批语:

版权申明:本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!

全部评论

文明上网理性发言,请遵守新闻评论服务协议

条评论
  • 博主信息
    大白鲸的博客
    博文
    23
    粉丝
    0
    评论
    1
    访问量
    13369
    积分:0
    P豆:229