六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

HTML與CSS中背景相關屬性

[摘要]這次給大家帶來HTML與CSS中背景相關屬性,使用HTML與CSS中背景相關屬性的注意事項有哪些,下面就是實戰案例,一起來看一下。一. 背景尺寸屬性1.什么是背景尺寸屬性 背景尺寸屬性是CSS3中新增的一個屬性, 專門用于設置背景圖片大小background-size:xxxx;取值:1.具體像素...
這次給大家帶來HTML與CSS中背景相關屬性,使用HTML與CSS中背景相關屬性的注意事項有哪些,下面就是實戰案例,一起來看一下。

一. 背景尺寸屬性

1.什么是背景尺寸屬性
背景尺寸屬性是CSS3中新增的一個屬性, 專門用于設置背景圖片大小

background-size:xxxx;

取值:

1.具體像素 >> background-size:200px 100px;
2.百分比 >> background-size:100% 80%;
3.寬度等比拉伸 >> background-size:auto 100px;
4.高度等比拉伸 >> background-size:100px auto;
5.cover >> background-size:cover;

5.1告訴系統圖片需要等比拉伸

5.2告訴系統圖片需要拉伸到寬度<a>和</a>高度都填滿元素

6. contain >> background-size:contain;

6.1告訴系統圖片需要等比拉伸

6.2告訴系統圖片需要拉伸到寬度<a>或</a>高度都填滿元素(<a>只保證一邊填滿</a>)

background-size

二. 背景圖片定位區域屬性

<a>background-origin</a> : 告訴系統背景圖片從什么區域開始顯示,默認情況下就是從padding區域開始顯示;

取值:

1.<a>padding-box</a>:默認值 >>background-origin: padding-box; 告訴系統背景圖片從什么區域開始顯示,默認情況下就是從padding區域開始顯示;
 2.<a>border-box</a> >>  background-origin:border-box; 從border位置開始
 3.<a>content-box</a> >>  background-origin:content-box;從content位置開始
<html lang="en"> <head>     <meta charset="UTF-8">     <title>113-背景圖片定位區域屬性</title>     <style>         *{             margin: 0;             padding: 0;         }         ul li{             list-style: none;             float: left;             width: 100px;             height: 100px;             text-align: center;             line-height: 100px;             border: 20px dashed #000;             padding: 50px;             margin-left: 20px;             background: url("images/dog.jpg") no-repeat;         }         ul li:nth-child(2){             /*             告訴系統背景圖片從什么區域開始顯示,             默認情況下就是從padding區域開始顯示             */             background-origin: padding-box;         }         ul li:nth-child(3){             background-origin:border-box;         }         ul li:nth-child(4){             background-origin:content-box;         }     </style> </head> <body> <ul>     <li>默認</li>     <li>padding</li>     <li>border</li>     <li>content</li> </ul> </body> </html>

背景圖片定位區域屬性

三. 背景繪制區域屬性

<a>background-clip:xxx;</a>背景繪制區域屬性是專門用于指定從哪個區域開始繪制背景的, 默認情況下會從border區域開始繪制背景
<html lang="en"> <head>     <meta charset="UTF-8">     <title>114-背景繪制區域屬性</title>     <style>         *{             margin: 0;             padding: 0;         }         ul li{             list-style: none;             float: left;             width: 100px;             height: 100px;             text-align: center;             line-height: 100px;             border: 20px dashed #000;             padding: 50px;             margin-left: 20px;             background: red url("images/dog.jpg") no-repeat;         }         ul li:nth-child(2){             /*             背景繪制區域屬性是專門用于指定從哪個區域開始繪制背景的, 默認情況下會從border區域開始繪制背景             */             background-clip: padding-box;         }         ul li:nth-child(3){             background-clip: border-box;         }         ul li:nth-child(4){             background-clip: content-box;         }     </style> </head> <body> <ul>     <li>默認</li>     <li>padding</li>     <li>border</li>     <li>content</li> </ul> </body> </html>

背景繪制區域屬性(紅色為繪制區域)

四. 多重背景圖片

<a>先添加的背景圖片會蓋住后添加的背景圖片</a>

元素c3之后可以設置多張背景圖片
多張背景圖片之間用逗號隔開即可

background: url("images/animal1.png") no-repeat left top,url("images/animal2.png") no-repeat right top,url("images/animal3.png") no-repeat left bottom;

注意點:

先添加的背景圖片會蓋住后添加的背景圖片

background: url("images/animal1.png") no-repeat left top,url("images/animal2.png") no-repeat right top,url("images/animal3.png") no-repeat left bottom,url("images/animal4.png") no-repeat right bottom,url("images/animal5.png") no-repeat center center;

建議在編寫多重背景時拆開編寫

background-image: url("images/animal1.png"),url("images/animal2.png"),url("images/animal3.png"); background-repeat: no-repeat, no-repeat, no-repeat; background-position: left top, right top, left bottom;

完整代碼如下:

<html lang="en"> <head>     <meta charset="UTF-8">     <title>115-多重背景圖片</title>     <style>         *{             margin: 0;             padding: 0;         }         p{             width: 500px;             height: 500px;             border: 1px solid #000;             margin: 0 auto;             /*             多張背景圖片之間用逗號隔開即可             注意點:             先添加的背景圖片會蓋住后添加的背景圖片             建議在編寫多重背景時拆開編寫             */             /*background: url("images/animal1.png") no-repeat left top,url("images/animal2.png") no-repeat right top,url("images/animal3.png") no-repeat left bottom,url("images/animal4.png") no-repeat right bottom,url("images/animal5.png") no-repeat center center;*/             background-image: url("images/animal1.png"),url("images/animal2.png"),url("images/animal3.png");             background-repeat: no-repeat, no-repeat, no-repeat;             background-position: left top, right top, left bottom;         }     </style> </head> <body> <p></p> </body> </html>


多重背景圖片

四.多重背景圖片聯系

<a>先添加的背景圖片會蓋住后添加的背景圖片</a>
<html lang="en"> <head>     <meta charset="UTF-8">     <title>116-多重背景圖片-練習</title>     <style>         *{             margin: 0;             padding: 0;         }         p{             width: 600px;             height: 190px;             border: 1px solid #000;             margin: 100px auto;                       background-image: url("images/bg-plane.png"),url("images/bg-sun.png"), url(images/bg-clouds.png);             background-repeat: no-repeat, no-repeat, no-repeat;             background-size: 50px 50px, 50px 50px, auto auto;          background-position: 50px 150px, 400px 50px, 0px 0px;             animation: move 10s linear 0s infinite normal;         }         @keyframes move {             from{                 background-position: 50px 150px, 400px 50px, 0px 0px;             }             to{                 background-position: 500px -150px, 400px 50px, -600px 0px;             }         }     </style> </head> <body> <p></p> </body> </html>

相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!

推薦閱讀:

HTML與CSS中2D轉換模塊

HTML與CSS中的過渡模塊

H5中的定位

以上就是HTML與CSS中背景相關屬性的詳細內容,更多請關注php中文網其它相關文章!


網站建設是一個廣義的術語,涵蓋了許多不同的技能和學科中所使用的生產和維護的網站。




主站蜘蛛池模板: 日本乱人伦片中文字幕三区 | 伊人婷婷色 | 亚洲伊人久久精品 | 日韩av线上 | 日韩一区二区在线观看 | 日本大片a | 婷婷国产 | 午夜免费啪视频观看网站 | 欧美一级特黄一片免费 | 在线天堂中文在线资源网 | 综合激情五月婷婷 | 中文字幕第66页永久乱码 | 日本视频高清 | 欧美一区不卡二区不卡三区 | 中文区永久区乱码六区 | 天堂在线最新版资源www | 日韩精品欧美激情国产一区 | 日韩插| 日本精品高清一区二区2021 | 欧美午夜一区二区福利视频 | 午夜伦理视频 | 日本久久伊人 | 亚洲第一男人网站 | 亚洲欧美日韩在线精品一区二区 | 五月婷婷伊人 | 夜鲁鲁鲁夜夜综合视频欧美 | 日本动态120秒免费 日本叼嗨 | 三级经典三级日本三级欧美 | 一级黄色大片免费 | 青娱在线| 中文字幕日韩精品在线 | 婷婷色香五月激情综合2020 | 亚洲欧美日韩综合久久久久 | 伊人男人天堂 | 日本国产精品 | 午夜在线观看视频在线播放版 | 青青网站| 欧美专区一区二区三区 | 伊人精品在线 | 在线视频韩国 | 午夜欧美精品久久久久久久久 |