写法如下:
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"
你看,背景就充满页面了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)