0
我有一些严重的困难让我的图像高度相对于浏览器窗口调整大小 - 宽度调整正常,但高度保持不变。我试过身高:100%和身高:自动,以及身高:100vh,但没有骰子。我敢肯定它是与我的div的布局方式,这里是有关CSS:动态调整大小的图像,相对/绝对定位?
.main {
z-index: 2;
width: 100%;
top: 0%;
height: auto;
left: 0%;
position: relative;
margin-bottom: 300px;
overflow: hidden;
}
.container {
overflow: auto;
}
.alphaleft {
background-color: #fff;
left: 0%;
top: 0%;
width: 50%;
height: 1000px;
position: relative;
padding: 0;
margin: 0;
z-index: 5;
float: left;
}
.alpharight {
background-color: #fff;
right: 0%;
top: 0%;
width: 50%;
height: 1000px;
position: relative;
padding: 0;
margin: 0;
z-index: 5;
float: right;
}
.alphaleftimg{
background: url("images/bg.png") no-repeat;
background-size: 100%;
left: 0%;
top: 20%;
width: 100%;
height: auto;
position: absolute;
padding: 0;
margin: 0;
z-index: 6;
}
.alpharightimg{
background: url("images/bg2.png") no-repeat;
background-size: 100%;
left: 0%;
top: 20%;
width: 100%;
height: auto;
position: absolute;
padding: 0;
margin: 0;
z-index: 6;
}
.floaters {
clear: both;
}
,这里是我的HTML的jsfiddle保存后长度:jsFiddle
我基本上希望页面看起来像这样:
与图像高度也随浏览器窗口缩放。
任何帮助,将不胜感激!谢谢!
是的,我的每幅图像都有背景大小:(问题是我需要自己的容器高度来自动调整图像的大小 – shanling 2013-04-28 07:29:44