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% */

 }

}

效果如:

用Dreamweaver软件编辑

一、打开Dreamweaver,然后选中html,出来了一个html标准文档。

二、在<body>标签里添加文件路径,语法如下:

<body background="文件路径">

这时,页面虽然充满了背景,但可以看出背景图片被填充了多次。

三、在<body>里添加样式,代码如下:

style=" background-repeat:no-repeat

background-size:100% 100%

background-attachment: fixed"

你看,背景就充满页面了。


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

原文地址: http://outofmemory.cn/zaji/6277576.html

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

发表评论

登录后才能评论

评论列表(0条)

保存