您好,登錄后才能下訂單哦!
這篇文章主要介紹css中的background-repeat屬性怎么用,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
CSSbackground-repeat屬性
作用:設(shè)置是否及如何重復(fù)背景圖像。
基本語法:
background-repeat:repeat|repeat-x|repeat-y|no-repeat;
repeat:默認(rèn)值,背景圖像將向垂直和水平方向重復(fù)。
repeat-x:只有水平位置會(huì)重復(fù)背景圖像。
repeat-y:只有垂直位置會(huì)重復(fù)背景圖像。
no-repeat:設(shè)置背景圖片不會(huì)重復(fù)。
說明:background-repeat屬性定義了圖像的平鋪模式。從原圖像開始重復(fù),原圖像由background-image定義,并根據(jù)background-position的值放置。
CSSbackground-repeat屬性的使用示例
<!DOCTYPEhtml>
<html>
<head>
<metacharset="utf-8">
<title>菜鳥教程(runoob.com)</title>
<style>
.demo1{
width:400px;
height:150px;
border:1pxsolidred;
background-image:url('https://img.php.cn/upload/article/000/000/024/5c6a4428ea867709.png');
background-repeat:repeat;
}
.demo2{
width:400px;
height:100px;
border:1pxsolidred;
background-image:url('https://img.php.cn/upload/article/000/000/024/5c6a4428ea867709.png');
background-repeat:no-repeat;
}
.demo3{
width:400px;
height:150px;
border:1pxsolidred;
background-image:url('https://img.php.cn/upload/article/000/000/024/5c6a4428ea867709.png');
background-repeat:repeat-x;
}
.demo4{
width:400px;
height:400px;
border:1pxsolidred;
background-image:url('https://img.php.cn/upload/article/000/000/024/5c6a4428ea867709.png');
background-repeat:repeat-y;
}
</style>
</head>
<body>
<h4>repeat設(shè)置背景圖片向垂直和水平方向重復(fù)</h4>
<divclass="demo1"></div>
<h4>no-repeat設(shè)置背景圖片不重復(fù)</h4>
<divclass="demo2"></div>
<h4>repeat-x設(shè)置背景圖片向水平方向重復(fù)</h4>
<divclass="demo3"></div>
<h4>repeat-y設(shè)置背景圖片向垂直方向重復(fù)</h4>
<divclass="demo4"></div>
</body>
</html>
以上是“css中的background-repeat屬性怎么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。