新聞中心
html5怎么設(shè)置整頁(yè)背景圖片
html5中設(shè)置整頁(yè)背景圖片的方法是利用css3樣式:
站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到東遼網(wǎng)站設(shè)計(jì)與東遼網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊(cè)、網(wǎng)絡(luò)空間、企業(yè)郵箱。業(yè)務(wù)覆蓋東遼地區(qū)。
寫(xiě)法如下:
img.bg {
/* Set rules to fill background */
min-height: 100%;
min-width: 1024px;
/* Set up proportionate scaling */
width: 100%;
height: auto;
/* Set up positioning */
position: fixed;
top: 0;
left: 0;
}
@media screen and (max-width: 1024px) { /* Specific to this particular image */
img.bg {
left: 50%;
margin-left: -512px; ? /* 50% */
}
}
效果如:
html5怎樣設(shè)置整頁(yè)背景圖片?
body{ ? ? ?font-family: "微軟雅黑";
width: 100%;
height:auto;
background:url("../img/....png") no-repeat;
background-size: 100%; ? }
在插入背景圖片的容器里設(shè)置background-size: 100%,這樣圖片就會(huì)覆蓋整頁(yè)。
html5 移動(dòng)端怎么固定背景圖片?
.body{
background:url(../image/pr_gb.png);//此處為你的圖片
background-repeat:no-repeat;
background-size:100% 100%;
}
fixed表示指定的背景是永遠(yuǎn)固定的,即:背景圖片不隨著網(wǎng)頁(yè)的滾動(dòng)而滾動(dòng)。
style
body {background-position: center;//背景居中
background-repeat: no-repeat;//無(wú)重復(fù)
background-attachment: fixed;//固定不動(dòng)}
/style
html5手機(jī)頁(yè)面背景圖片自適應(yīng)大小問(wèn)題
1,輸入position:fixed;top:0;left:0;將整個(gè)div固定在屏幕的頂部和左側(cè)。
2、輸入width:100%;height:100%;min-width:1000px;這個(gè)可以適合div的高度和寬度,而min-width是為了實(shí)現(xiàn)讓屏幕寬度在1000px以內(nèi)時(shí),div的大小保持不變。
3、輸入background-size: cover;-webkit-background-size: cover;-o-background-size: cover;使圖片隨屏幕大小同步縮放,但是有部分可能會(huì)被裁切,不過(guò)不至于會(huì)露白,下面兩句是為chrome和opera瀏覽器作兼容。
4、輸入background-position:center0;使圖片的位置,居中,靠左對(duì)齊。
文章標(biāo)題:html5背景圖,html5背景圖片代碼
URL分享:http://fisionsoft.com.cn/article/dsiphdd.html