一、div與span
(1)區塊級標籤:div(2)內嵌標籤:span如圖所示:
註:可用瀏覽器的調試工具可查看盒子
(2)padding:
(3)border:盒子邊框寬度(4)width:盒子寬度
①:外邊距和內邊邊距區別:
<!doctype html> <html> <head> <title>Div+Css布局(div+span以及盒模型)</title> <meta charset="utf-8"> <style type="text/css"> body{ margin:0; padding:0; background:#C5C1AA; } div{ height:500px; margin:60px; padding:o; border:solid 2px black; background-color:rgba(255,0,0,0.7); } div.div1{ height:400px; margin:0 audio; border:solid 3px black; background-color:rgba(0,0,255,0.7); } </style> </head> <body> <div> <div class="div1"> <h1 id="欢迎登录系统">欢迎登录系统</h1> <h4 id="账号-input-nbsp-style-text">账号:<input style="text"></h4> <h4 id="密码-input-nbsp-style-text">密码:<input style="text"></h4> </div> </div> </body> </html>
②:盒子模型div擺放範例:
demo.html
<!doctype html> <html> <head> <title>Div+Css布局(div+span以及盒模型)</title> <meta charset="utf-8"> <style type="text/css"> body{ margin:0; padding:0; background-color:rgba(0,0,255,0.3); } div{ width:500px; height:500px; background-color:rgba(250,128,10,0.8); margin:0 auto; /* 使div居中*/ border:solid black; } div.div1{ float:left; /* 向左排列/* background-color:rgba(255,0,0,0.4); border:solid blue; height:244px; width:244px; margin:0; padding:0; } </style> </head> <body> <div> <div class="div1"></div> <div class="div1"></div> </div> </body> </html>三、佈局相關的屬性(重要)
(1)position.父元素進行定位:absolute③.根據瀏覽器視窗進行定位: fixed④.沒有定位:static⑤.繼承:inherit(2)定位①.left:XXpx(左)離頁頂點的距離②.right:XXpx(右)離頁面頂點的距離③.top:XXpx(上)離頁面頂點的距離④.bottom:XXpx(下)離頁面頂點的距離(3)z-index 層覆蓋先後順序(優先權)①.-1,0 ,1,2,3;當為-1時,該圖層為最底層
①.display:none 層不顯示
② .display:block 塊狀顯示,在元素後面換行,顯示下一個塊元素③.display:inline 內聯顯示,多個塊可以顯示在一行內
①.left:左浮動
②.right:右浮動
[b](6)clear 清除浮動[/b]
①.clear:both
[b](7)overflow 溢出處理[/b]
①.層大小的內容
②.scroll無論內容是否超出層大小都添加滾動條
③.auto 超出時自動添加滾動條
[b]範例:[/b]
①:固定位置與demo
<!doctype html> <html> <head> <title>Div+Css布局(布局相关的属性)</title> <meta charset="utf-8"> <style type="text/css"> body{ padding:0; margin:0; } div.diva{ position:relative; /* 一定要添加,如没添加其子元素则不生效*/ margin:50px; width:500px; height:500px; background-color:rgba(255,0,0,0.4); } .spanb{ position:absolute; background-color:blue; color:black; top:-10px; right:0; } .fixed{ padding:20px; background:green; position:fixed; left:0; top:40px; z-index:1; /* z-index的value值可为-1,0,1,2;当为-1时,该图层为最底层 */ } </style> </head> <body> <div class="fixed"> <p>联系人:翁孟铠</p> <p>联系电话:XXXxxxx</p> <p>地址:XXXXXXXXXXX</p> </div> <div class="diva"> <span class="spanb">浏览次数:222</spn> </div> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> </body> </html>
②:浮動與溢出效果demo
<!doctype html> <html> <head> <title>Div+Css布局(浮动以及溢出处理)</title> <meta charset="utf-8"> <style type="text/css"> body{ padding:0; margin:0; } .div{ width:auto; height:auto; background:#f1f1f1; margin:0 auto; color: black; } .left{ width: 300px; height: 400px; position: inherit; top: 60px; background:yellow; float: left; color: black; } .right{ float: left; width: 1049px; height: 400px; position: inherit; top: 60px; background:lavenderblush; color: black; } .top{ width: auto; height: 60px; background: royalblue; position: inherit; top:0; } .bottom{ clear: both; margin-top:20px; width: 960px; height: 20px; background: red; } .jianjie{ height: 80px; width: 200px; background: brown; overflow: auto; } </style> </head> <body> <div class="div"> <div class="top">logo</div> <div class="left">左边</div> <div class="right"> 简介:<br> <div class="jianjie"> 1、这是简介<br> 2、我们在做溢出测试<br> 3、hidden 隐藏超出层大小的内容<br> 4、scroll无论内容是否超出层大小都添加滚动条<br> 5、auto 超出时自动添加滚动条 </div> </div> <div class="bottom"></div> </div> </body> </html>
以上就是css折疊樣式(4)――div+css佈局的內容,更多相關內容請關注PHPcn(www.php. )!

當他們在2013年去Chrome時,我們失去了歌劇。與Edge今年早些時候也進行了同樣的交易。邁克·泰勒(Mike Taylor)稱這些變化為“減少

在本週的綜述中,Apple進入Web組件,Instagram如何插入腳本以及一些思考的食物,以進行自託管關鍵資源。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

WebStorm Mac版
好用的JavaScript開發工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

Dreamweaver Mac版
視覺化網頁開發工具

禪工作室 13.0.1
強大的PHP整合開發環境

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。