简体   繁体   English

尽可能调整Div纯CSS的大小

[英]Resize Div pure CSS if possible

I have the following HTML structure: 我有以下HTML结构:

<div class="outer">
<div class="inner">
<a href="#"/>
<a href="#"/>
<a href="#"/>
</div>
</div>

And CSS: 和CSS:

div.outer{
    position:relative;
    height:177px;
    width: 495px;
    margin: 0 10px 0 10px;
    overflow: hidden;
} 
div.inner{
    position: absolute; 

}

How is it possible to resize the outer div dinamically ? 如何动态地调整外部div的大小? Height min-max does not work. 高度最小-最大不起作用。 Thank you ! 谢谢 !

For this to work the way I think you want it to work, then you'd need to use all three declarations: min-height , height and max-height , with the height being a relative measure, and the min-height and max-height both used to constrain that relative sizing to an appropriate minimum or maximum. 为了使它按我认为您希望的方式工作,那么您需要使用所有三个声明: min-heightheightmax-height ,其中height是相对度量,而min-heightmax-height都用于将相对大小限制为适当的最小值或最大值。 For example: 例如:

.outer {
    overflow: auto;
    margin: 0 auto;
    width: 50%;
    border: 2px solid #000; /* The above just for aesthetics, adjust to change */
    min-height: 100px;
    height: 50%;
    max-height: 1000px;
}

JS Fiddle demo JS小提琴演示

In the demo, resize the window to cause the 'preview' pane to expand/contract to see the effects. 在演示中,调整窗口大小以使“预览”窗格扩展/收缩以查看效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以使用纯CSS根据包含的图像宽度来调整div的宽度,但不能在浏览器窗口调整大小时进行调整? - Is it possible to use pure CSS to resize a div's width based on contained image width, but not when browser window resizes? 是否有可能使用纯css使父div调整大小以适应内联块白色空间nowrap内容 - is it possible with pure css to make parent div resize to fit inline-block white-space nowrap content 带有 div 且没有类或 id 的纯 css 棋盘,这可能吗? - Pure css Chessboard with div & no classes or ids, is it possible? 具有纯 css 的可调整大小的 div - resizable div with pure css (大)div在较小的div内水平居中。 纯CSS解决方案可能吗? - (Large) div horizontally centered inside smaller div. Pure CSS solution possible? 使用纯CSS在未知尺寸的div内的9个可能位置中的任意一个位置上的未知尺寸的img | span | div位置 - position img|span|div of unknown dimensions in any of 9 possible positions within a div of unknown dimensions using pure CSS CSS,自动调整大小div? - CSS, auto resize div? Div用纯CSS向上滑动 - Div slide up with pure css 使用纯CSS定位div - Position div using pure css 纯CSS中的响应式正方形,位于任意大小的div元素的右上方-可能吗? - A responsive responsive-square in pure CSS positioned to the top right of a div element of any size - possible?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM