#div_left_sidebar{
margin:10px auto 10px 10px;
border:0px #00ff00 solid;
background: url(images/side_beijing.jpg) #CCC no-repeat left top;
width: 200px;
height:600px;}
side_beijing.jpg的大小是364X775,请问,怎么能够在不改变图片大小的情况下,让这张背景图能够自动适应div的尺寸,如果图片尺寸比div定义的尺寸小又该怎么办,谢谢给位老师指教!
background-size: cover;
background-size: cover;
成功,太感谢了,还有一个问题,
我在一个div_main中嵌套了三个层,请问怎么才能达到并排排列的效果,第二,三个层我用了绝对定位还是不行,请指教,谢谢!
css代码:
#div_main{
padding:0px;
width:1000px;
background:url(images/div_main_beijing.jpg) #CCC no-repeat left top;
margin:20px auto auto auto;
border: 1px #CCC solid;
}
#div_left_sidebar{
margin:10px auto 10px 10px;
border:0px #00ff00 solid;
background: url(images/side_beijing.jpg) #CCC no-repeat left top;
background-size:cover;
width: 200px;
height:600px;
}
#div_zhongjian_sidebar{
position:absolute;
left:220px;
top:10px;
margin:10px auto 10px auto;
border:0px #00ff00 solid;
background: url(images/zhongjian_beijing.jpg) #CCC no-repeat left top;
background-size:cover;
width: 560px;
height:600px;
}
#div_right_sidebar{
position:absolute;
left:790px;
top:10px;
margin:10px 10px 10px auto;
border:0px #00ff00 solid;
background: url(images/side_beijing.jpg) #CCC no-repeat left top;
background-size:cover;
width: 200px;
height:600px;
页面代码:
#div_main >div{
float:left;
}
position:absolute; 走掉
#div_main >div{
float:left;
}
position:absolute; 走掉
请问这个是写在样式表里单独一行么?不好意思小弟初涉css不太懂,麻烦给讲解一下,谢谢!
而且感觉中间和右边的层不在main曾里面,