我正在使用bootstrap2进行设计
<div class="row">
<div class="span-4">
</div>
<div class="span-8">
<div id="expandable" style="width:100%">
here I want to change the height of this div according to the width size.
</div>
</div>
</div>当我拖动浏览器时,它会改变'span-8‘div的大小。
我想保持4:3的高度和宽度。
例如,当宽度为400时,我希望保持高度300。宽度为200米时,应为150米
有可能吗?
发布于 2014-03-28 09:04:48
我已经回答了这个问题,这里。重点是使用虚拟div和绝对定位的div使响应元件具有固定的纵横比。此解决方案仅使用CSS。
为了使其适应您的情况,您可以这样做:
演示
HTML:
<div class="row">
<div class="span-4"></div>
<div class="span-8">
<div class="expandable">
here I want to change the height of this div according to the width size.
</div>
<div class="dummy"></div>
</div>
</div>CSS:
.span-8 {
position: relative;
}
.dummy {
padding-top: 75%;
}
.expandable {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background:gold;
}https://stackoverflow.com/questions/22706038
复制相似问题