写法如下:
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% */
}
}
效果如:
步骤一、首先打开需要修改的HTML文件。
步骤二、然后始化样式,将代码添加在<style></style>标签内。
步骤三、添加一个div容器,然后命名为bg-box
步骤四、背景全屏需要容器全屏,将bg-box的样式补全。
步骤五、设置完毕,图片背景以及全屏了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)