background-origin篇
<!DOCTYPE?html> <html> <head>? <meta?charset="utf-8"> <title>背景原點</title> <style?type="text/css"> .wrap?{ ????width:220px;? ????border:20px?dashed?#000;? ????padding:20px;? ????font-weight:bold;? ????color:#000;? ????background:#ccc?url(http://static.mukewang.com/static/img/logo_index.png)?no-repeat;? ????background-origin:?content-box; ????position:?relative; } .wrap?span?{? ????position:?absolute;? ????left:0;? ????top:0; } .content?{ ????height:80px;? ????border:1px?solid?#333; } </style>?? </head>? <body> <div?class="wrap"><span>padding</span> ????<div?class="content">content</div> </div> <br/> </div> </body> </html>
.content 未設(shè)置width,為什么他有160px左右的寬度
2015-12-06
.content ?是在div上的,div是一個塊級元素,塊級元素不設(shè)置寬度,默認(rèn)就是父級元素的寬度,所以他有他的父級元素的內(nèi)寬度就是220px ?
2022-03-23
你好,可以的這你要理解if...elseif...else的判斷機制,他是當(dāng)第一個條件不成立時直接進行第二個條件,依次類推,所以你在第二個和后面是不需要多余的條件語句的