日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

HTML CSS 背景图居中属性background-position

發布時間:2024/1/8 HTML 50 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HTML CSS 背景图居中属性background-position 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

HTML CSS背景圖居中(無序列表)

--背景重復:backgroung-repeat:--no-pepeat:不重復--repeat-x:水平水平方向平鋪; --repeat-y:垂直方向平鋪--背景位置:background-position(x,y):--屬性值分水平和垂直方向:-- 水平方向: left/center/ight;-- 垂直方向: top/center/bottom :--background-position:right;表示圖片右居中,兩個屬性當只設置一個時,另外一個默認為center--背景大小設置: background-size--按高度等比縮放: contain--按寬度等比縮放: cover完全按照容器大小進行100%縮放: background-size:100% 100%; <!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>漸變背景</title><style>ul {width: 260px;list-styLe: none;padding: 0 40px 0 0;/* border: 1px solid red; */}li {width: 300px;height: 40px;border: 1px solid red;background: url("imgurl");background-repeat: no-repeat;background-position: right;}/* --背景重復:backgroung-repeat:--no-pepeat:不重復--repeat-x:水平水平方向平鋪; --repeat-y:垂直方向平鋪--背景位置:background-position(x,y):--屬性值分水平和垂直方向:-- 水平方向: left/center/ight;-- 垂直方向: top/center/bottom :--background-position:right;表示圖片右居中,兩個屬性當只設置一個時,另外一個默認為center--背景大小設置: background-size--按高度等比縮放: contain--按寬度等比縮放: cover完全按照容器大小進行100%縮放: background-size:100% 100%;*/</style> </head><body><div><ul><li>第三年初</li><li>奪萃比無無無無</li><li>而紛紛發文</li></ul></div> </body> </html>

背景圖居中屬性background-position

<!DOCTYPE html> <html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>漸變背景</title><style>.box {width: 400px;height: 400px;border: 1px solid gold;background-color: mediumpurple;background-image: url("imgurl");/* 圖片大小 */background-size: 100% 100%;/* 不重復 */background-repeat: no-repeat;/* 居中 水平、垂直居中 */background-position: center center;}</style> </head><body><div class="box"></div> </body></html>

總結

以上是生活随笔為你收集整理的HTML CSS 背景图居中属性background-position的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。