<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>css+vid</title> <style type="text/css"> /* margin 塌陷效果,上下元素|標籤之間使用margin,並非累加,而是採用marain大的值 margin的縮寫 margin:10px,四邊的margin都爲10px margin:10px 20px;上下margin爲10px,左右margin爲20px margin:10px 20px 30px; 上margin爲10px 左右margin爲20px,下margin爲30px margin:10px 20px 30px 40px;起始位置上margin爲10px,按順時針排列 對於塊級元素|標籤,水平居中 width:***px; margin:0 auto; padding內填充,內容與邊框線之間 padding縮寫同margin padding不佔用width、height空間 border border-width:thin|thick|1px|2px; border-color: red|green|white|#f90|grb(0-255,g十進制,b十進制); border-style:solid|dotted(點線)|dashed; border-top:5px #000 solid;某邊的線條 border:5px #000 solid;四邊線條 www.w3scholl.com.cn */ body{ margin: 0; } .box1{ width: 1000px; height: 200px; background-color: #666; margin:0px auto 0px auto; border-top: 5px red solid; border-right: 5px yellow solid; border-bottom: 5px blue solid; border-left: 5px pink solid; } .box2{ height: 600px; width: 1000px; background-color: green; margin: 0px auto 0px auto; padding: 0px </style> </head> <body> <div class="box1"></div> <div class="box2">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic rerum autem illum quae, obcaecati, sit ducimus, fuga delectus expedita officia voluptatibus ipsum. Dicta possimus, pariatur error, nulla distinctio atque tempora!</div> </body> </html>
網站開發學習網站www.w3scholl.com.cncss