這篇文章將為大家詳細講解有關Html5中背景屬性的示例分析,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網綜合服務,包含不限于成都網站設計、成都網站建設、良慶網絡推廣、小程序設計、良慶網絡營銷、良慶企業(yè)策劃、良慶品牌公關、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)公司為所有大學生創(chuàng)業(yè)者提供良慶建站搭建服務,24小時服務熱線:18980820575,官方網址:www.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ū)域開始顯示背景
padding-box: 從padding區(qū)域開始顯示背景
content-box: 從content內容區(qū)域開始顯示背景
background-clip 背景繪制區(qū)域
border-box: 從border區(qū)域開始繪制背景
padding-box: 從padding區(qū)域開始繪制背景
content-box: 從content內容區(qū)域開始顯示背景
3、背景練習代碼部分:
<!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>注釋:復合寫background-size的時候,一定要用/與其他值隔開。</p>
</section>
</p>
</body>
</html>5、背景練習preview:
關于“Html5中背景屬性的示例分析”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
網站名稱:Html5中背景屬性的示例分析
網址分享:http://www.chinadenli.net/article6/gisiog.html
成都網站建設公司_創(chuàng)新互聯(lián),為您提供網站制作、面包屑導航、做網站、網站維護、服務器托管、響應式網站
聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)