Blogger Information
Blog 29
fans 0
comment 1
visits 18780
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
3.23php中文网学习第7节课作业
小小的菜的博客
Original
616 people have browsed it

代码


实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>0323作业</title>
	<style type="text/css">
		/*关于水平居中
		1.父元素内为行内元素,多行行内元素,不定宽块元素的,都是通过设置父元素text-align:center属性实现子元素水平居中
          2.不定宽的块元素需要先将子元素display属性值转为display:inline,然后在设置父元素text-align属性;*/
          .box1 {
          	width:200px;
          	height: 200px;
          	text-align: center;
          	background-color:blue;
          }
          .box1 span {
          	line-height: 200px;
          }
          .box2 {
          	width:200px;
          	height: 200px;
          	/*设置水平居中*/
          	text-align: center;
          	background-color:brown;
          	/*转为单元格*/
          	display: table-cell;
          	/*设置垂直居中*/
          	vertical-align:middle;
          }
          .box3 {
          	width: 200px;
			height: 200px;
			background-color: red;
			/*转为单元格*/
			display: table-cell;  
			/*设置垂直居中*/
			vertical-align: middle; 
          }
          .box3 .text {
          	background-color: yellow;
          	width:100px;
          	/*通过设置margin:auto来实现水平居中*/
          	margin:auto;
          }
          .box4 {
          	width: 200px;
			height: 200px;
			background-color: green;
			/*设置水平居中*/
			text-align: center;
            display: table-cell; 
			/*vertical-align:bottom; */
          }
          
          .box4 ul {
          	margin: 0;
          	padding: 0;          
          	line-height: 200px;
          }
          .box4 li {
            list-style: none;
          	display: inline;

          }
	</style>
</head>
<body>
	<div class="box1">
		<span>一行行内元素</span>
	</div>
	<hr>

    <div class="box2">
    	<span>我里面有多行行内元素,不信你自己看。</span>
    </div>
    <hr>

    <div class="box3">
    	<p class="text">我是一个块元素</p>
    </div>
    <hr>

    <div class="box4">
    	<ul>
    		<li>1</li>
    		<li>2</li>
    		<li>3</li>
    		<li>4</li>
    		<li>5</li>
    	</ul>
    </div>
</body>
</html>

运行实例 »

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

手抄

0323作业1.png0323作业2.png

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post