因为我想要一个固定高度的栏和一个占据页面其余部分的 map ,所以这会很棒。
我已经试过了:
#header{
position:fixed;
top:0;
left:0;
width:100%;
height:30pt;
background-color:#ff0066;
z-index:2;
}
//element to reduce
#map{
position:absolute;
height: 100%;
width: 100%;
background-color:blue;
margin-top:30pt;
margin-bottom:-30pt;
}
如果创建了这个 fiddle : http://jsfiddle.net/bmPpq/
附言我积极在网上搜索解决方案,但没有成功(除了使用 JS,但那很糟糕..)
基本上这就是我想要的:
#map{
height: 100% - 30pt;
}
最佳答案
您可以在 map 上使用最小高度。 这应该有效:
#map{
min-height: 100%;
width: 100%;
height: auto;
position: fixed;
top: 30;
left: 0;
background-color:blue;
}
关于html - 有没有办法减少带有边距或其他元素的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13542281/