博主信息
博文 43
粉丝 0
评论 0
访问量 33633
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
四种元素居中方法、十字架制作+2018年8月17日
Lee的博客
原创
770人浏览过

四种元素居中的方法:

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>第四节作业</title>
	<style>
		.box{
			width: 200px;
            height: 200px;
            background-color: GreenYellow;
            text-align: center;
            line-height: 200px;
		}
		.box2{
			width: 200px;
            height: 200px;
            background-color: HotPink;
            text-align: center;
            display: table-cell;
            vertical-align: middle;
        }
        .box4{
        	width: 200px;
            height: 200px;
            background-color: LightSteelBlue;
            text-align: center;    
            display: table-cell;
            vertical-align: middle;  
        }
        .child{
        	width: 100px;
        	height: 100px;
        	background-color: Lime;
        	margin: auto;
        	line-height: 100px;
        	font-size: 12px;
        }
        .box5{
        	width: 200px;
            height: 200px;
            background-color: MediumSlateBlue;
            text-align: center;
            display: table-cell;
            vertical-align: middle;

        }
        .box5 li{
        	display: inline;
        	font-size: 12px;
        }
        .box5 ul{
        	padding: 0;
        }

	</style>
</head>
<body>
	<div class="box"><span>子元素是单行行内元素</span></div>
	<hr>
	<div class="box2"><span>子元素是</span><br><span>多行的内联文本</span></div>
	<hr>
	<div class="box4"><div class="child">子元素是块元素</div></div>
	<hr>
	<div class="box5">
		<ul>
		<li><a href=""></a>子元素</li>
		<li><a href=""></a>是不定</li>
		<li><a href=""></a>宽的</li>
		<li><a href=""></a>块级元素</li>
	    </ul>
    </div>
</body>
</html>

运行实例 »

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


十字架制作:

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>第四节作业2</title>
	<style>
		.box1{
			 width: 750px;
             height: 750px;
             background-color: LightSteelBlue;
             position: relative;
             margin: 0 auto;
		    }
		 .box2{
             width: 250px;
             height: 250px;
             background-color: MediumTurquoise;
             position: absolute;
             left: 250px;
		 }
		 .box3{
		 	 width: 250px;
             height: 250px;
             background-color: MistyRose;
             position: absolute;
             top: 250px;
		 }
		 .box4{
		 	 width: 250px;
             height: 250px;
             background-color: PaleVioletRed;
             position: absolute;
             right: 0;
             top: 250px;
         }
         .box5{
		 	 width: 250px;
             height: 250px;
             background-color: SpringGreen;
             position: absolute;
             bottom: 0;
             left: 250px;
         }
	</style>
</head>
<body>
	<div class="box1">
		<div class="box2"></div>
	    <div class="box3"></div>
	    <div class="box4"></div>
	    <div class="box5"></div>
</div>
	
</body>
</html>

运行实例 »

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


运行示例:

QQ截图20180817133153.png

QQ截图20180817133203.png


总结:本次作业不复杂,但是可以学习到简单的css的网页布局方法

批改状态:合格

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学