html5怎么设置整页背景图片

html5怎么设置整页背景图片,第1张

html5中设置整页背景图片的方法是利用css3样式

写法如下:

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的样式补全。

步骤五、设置完毕,图片背景以及全屏了。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11825148.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-19
下一篇 2023-05-19

发表评论

登录后才能评论

评论列表(0条)

保存