這篇文章將為大家詳細(xì)講解有關(guān)Html5中背景屬性的示例分析,小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。
創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、良慶網(wǎng)絡(luò)推廣、小程序設(shè)計(jì)、良慶網(wǎng)絡(luò)營(yíng)銷、良慶企業(yè)策劃、良慶品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供良慶建站搭建服務(wù),24小時(shí)服務(wù)熱線:18980820575,官方網(wǎng)址:chinadenli.net
1、背景屬性屬性:
background-image
background-color
background-repeat
background-position
background-attachment
2、新增屬性:
background-size:
background-size:x y; // 水平 垂直方向的尺寸,像素/百分比/auto/?
background-size:cover; //保持寬高比不變,保證占滿盒子,但不保證能看到全部
background-size:contain; //保持寬高比不變,保證看清全圖,但可能占不滿盒子
多背景:
background-image:url(1.jpg),url(2.jpg);
background-origin 背景區(qū)域定位
border-box: 從border區(qū)域開(kāi)始顯示背景
padding-box: 從padding區(qū)域開(kāi)始顯示背景
content-box: 從content內(nèi)容區(qū)域開(kāi)始顯示背景
background-clip 背景繪制區(qū)域
border-box: 從border區(qū)域開(kāi)始繪制背景
padding-box: 從padding區(qū)域開(kāi)始繪制背景
content-box: 從content內(nèi)容區(qū)域開(kāi)始顯示背景
3、背景練習(xí)代碼部分:
<!DOCTYPE HTML> <html> <head> <title>your title name</title> <meta charset="utf-8"> <meta name="Author" content="Wilson Xu"> <style type="text/css"> *{margin: 0;padding: 0;font-family: "Microsoft yahei";} a{text-decoration: none;} a img{display: block;border: none;} li{list-style: none;} .container{ width: 1200px; padding: 20px; margin: 10px auto; border: 1px dashed #ccc; } .container h5{padding-bottom: 5px;} .container ul{ width: 1200px; overflow: hidden; } .container ul li{ float: left; width: 331px; padding: 20px; height: 240px; margin-right: 10px; border: 10px solid rgba(10,10,10,.3); background: url('images/1.jpg') no-repeat; background-size: 371px auto; } .container ul li:last-child{margin-right: 0;} .container ul.origin li:nth-child(1){ background-origin: border-box; } .container ul.origin li:nth-child(2){ background-origin: padding-box; } .container ul.origin li:nth-child(3){ background-origin: content-box; } .container ul.clip li:nth-child(1){ background-clip: border-box; } .container ul.clip li:nth-child(2){ background-clip: padding-box; } .container ul.clip li:nth-child(3){ background-clip: content-box; } section .pic{ width: 600px; height: 400px; margin: 20px auto; border: 1px dashed #ddd; background: url('images/3.jpg') no-repeat center center/auto 200px, url('images/2.jpg') no-repeat center center/auto 300px, url('images/1.jpg') no-repeat center center/auto 400px; } section p{ font-size: 14px; color: #f01010; } </style> </head> <body> <p class="container"> <section> <h5>1、background-origin: border-box | padding-box | content-box</h5> <ul class="origin"> <li></li> <li></li> <li></li> </ul> </section> <section> <h5 style="margin-top: 20px;border-top: 1px dashed #ccc;">2、background-clip: border-box | padding-box | content-box</h5> <ul class="clip"> <li></li> <li></li> <li></li> </ul> </section> <section> <h5 style="margin-top: 20px;border-top: 1px dashed #ccc;">3、多背景:background: url('images/3.jpg') no-repeat center center/auto 200px, url('images/2.jpg') no-repeat center center/auto 300px, url('images/1.jpg') no-repeat center center/auto 400px; </h5> <p class="pic"></p> <p>注釋:復(fù)合寫(xiě)background-size的時(shí)候,一定要用/與其他值隔開(kāi)。</p> </section> </p> </body> </html>
5、背景練習(xí)preview:
關(guān)于“Html5中背景屬性的示例分析”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。
網(wǎng)站名稱:Html5中背景屬性的示例分析
網(wǎng)址分享:http://chinadenli.net/article6/gisiog.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、面包屑導(dǎo)航、做網(wǎng)站、網(wǎng)站維護(hù)、服務(wù)器托管、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)