亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

搜索
博主信息
博文 35
粉絲 0
評論 0
訪問量 40055
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板
盒模型,定位與浮動作業(yè)-2018-8-17
THPHP
原創(chuàng)
1017人瀏覽過

內(nèi)外邊距:


實例

<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="Keywords" content="關(guān)鍵字">
		<meta name="Description" content="描述">
		<title>內(nèi)外邊距</title>
		<style>
			*{margin:0;padding:0;}
			.box{
				width:400px;
				height:400px;
				background:#003399;
				/* margin-top:20px; 順時針:上 右 下 左
				margin-left:30px;
				margin-right:40px;
				margin-bottom:50px; */
				margin:20px 40px 50px 30px;/*  margin 簡寫 */
				border-top:10px solid #66cc00;
				border-left:20px solid #6633ff;
				border-bottom:30px solid #99cc66;
				border-right:40px solid #ff0000; 
				/* padding-top:20px; 順時針:上 右 下 左
				padding-left:30px;
				padding-bottom:40px;
				padding-right:50px; */
				padding:20px 50px 40px 30px; /* paddign 簡寫 */
			}
		</style>
	</head>
	<body>
		<div class="box"></div>
	</body>	
</html>

運行實例 ?

點擊 "運行實例" 按鈕查看在線實例

常用的四個方式的元素對齊方式:


實例

<!doctype html>
<html lang="en">
	<head>
		<meta charset="utf-8">
		<meta name="Keywords" content="關(guān)鍵字">
		<meta name="Description" content="描述">
		<title>元素對齊方式</title>
	</head>
	<body>
		<!-- 子元素對齊方式 -->
		<style>
			/* 子元素對齊方式:在父級元素 填寫:text-align:center; line-height:200px; 實現(xiàn)對齊 */
			.box{
				width:200px;
				height:200px;
				margin:auto;
				background:#669966;
				font-size:20px;
				text-align:center;/* 水平居中 */
				line-height:200px;/* 垂直居中 */
			}
			.box a{
				color:#fff;
			}
		</style>
		<div class="box">
			<a href="#">php中文網(wǎng)</a>
		</div>
		<!-- 子元素是多行的內(nèi)聯(lián)文本 -->
		<style>
			/* 子元素是多行的內(nèi)聯(lián)文本時: 在父元素填寫: text-align: center;display:table-cell; vertical-align:來對齊 */
			.box1{
				width:200px;
				height:200px;
				background:#669966;
				font-size:20px;
				color:#fff;
				text-align:center;/* 水平居中 */
				display:table-cell; /* 設(shè)置此屬性,margin失效 */
				vertical-align:middle;/* 垂直居中 */
			}
			.box1 p{
				margin:0;
			}
		</style>
		<div class="box1">
			<p>php中文網(wǎng)</p>
			<p>免費學(xué)習(xí)平臺</p>
		</div>
		<!-- 子元素是塊元素 -->
		<style>
			/* 子元素是塊元素:在父級元素填寫 display:table-cell;
				vertical-align:middle;
				子元素填寫:margin:auto; 來對齊
				*/
			.box3{
				width:200px;
				height:200px;
				background:#ff3333;
				display:table-cell;
				vertical-align:middle;
			}
			.box3 p{
				width:50px;
				height:50px;
				background:#eee;
				margin:auto;
			}
		</style>
		<div class="box3">
			<p>塊元素</p>
		</div>
		<!-- 子元素是不定寬的塊元素 -->
		<style>
			/* 在父級元素填寫:display:table-cell;vertical-align:center;
			子元素轉(zhuǎn)為行內(nèi)元素:display:inline; */
			.box4{
				width:500px;
				height:150px;
				background:#663399;
				margin-top:20px;
				padding-left:0;
				display:table-cell;
				vertical-align:bottom; /* 頂部對齊 */
				font-size:20px;
				color:#fff;
			}
			.box4 li{
				display:inline;
			}
		</style>
		<ul class="box4">
			<li>1</li>
			<li>2</li>
			<li>3</li>
			<li>4</li>
		</ul>
	</body>
</html>

運行實例 ?

點擊 "運行實例" 按鈕查看在線實例

用5個不同色塊,使用定位屬性來寫十字架:


實例

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <title>十字架</title>
  <style>
	*{margin:0;padding:0;}
	.box{
		width:800px;
		height:600px;
		border:1px solid red;
		margin:auto;
		position:relative;
		background-color:#eee;
	}
	.box1{
		width:70px;
		height:160px;
		background:#006600;
		margin:auto;
	}
	.box2{
		width:70px;
		height:70px;
		background:#990099;
		margin:auto;
	}
	.box3{
		width:180px;
		height:70px;
		background:#66ffcc;
		position:absolute;
		left:185px;
		top:160px;
	}
	.box4{
		width:180px;
		height:70px;
		background:#ff0033;
		position:absolute;
		top:160px;
		right:185px;
	}
	.box5{
		width:70px;
		height:160px;
		background:#0000cc;
		margin:auto;
	}
  </style>
 </head>
 <body>
	<div class="box">
		<div class="box1"></div>
		<div class="box2"></div>
		<div class="box3"></div>
		<div class="box4"></div>
		<div class="box5"></div>
	</div>
 </body>
</html>

運行實例 ?

點擊 "運行實例" 按鈕查看在線實例


批改狀態(tài):合格

老師批語:
本博文版權(quán)歸博主所有,轉(zhuǎn)載請注明地址!如有侵權(quán)、違法,請聯(lián)系admin@php.cn舉報處理!
全部評論 文明上網(wǎng)理性發(fā)言,請遵守新聞評論服務(wù)協(xié)議
0條評論
關(guān)于我們 免責(zé)申明 意見反饋 講師合作 廣告合作 最新更新
php中文網(wǎng):公益在線php培訓(xùn),幫助PHP學(xué)習(xí)者快速成長!
關(guān)注服務(wù)號 技術(shù)交流群
PHP中文網(wǎng)訂閱號
每天精選資源文章推送
PHP中文網(wǎng)APP
隨時隨地碎片化學(xué)習(xí)
PHP中文網(wǎng)抖音號
發(fā)現(xiàn)有趣的

Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號

  • 登錄PHP中文網(wǎng),和優(yōu)秀的人一起學(xué)習(xí)!
    全站2000+教程免費學(xué)