简体   繁体   English

如何将DIV调整到小于其初始宽度和高度?

[英]How to resize DIV to less than its initial width & height?

I want to give the user the ability to resize a DIV to less than its declared width and height. 我想让用户能够将DIV的大小调整为小于其声明的宽度和高度。 How to ? 如何 ?

Code here: http://jsfiddle.net/hW4nn/ 代码在这里: http//jsfiddle.net/hW4nn/

HTML HTML

<div class="divClass"></div>

CSS CSS

.divClass {
    resize: both;
    overflow: auto;
    width: 200px;
    height: 200px;
    border: 1px dotted #000;
}

As far as I know, the browser will not let you resize any smaller than the initial size. 据我所知,浏览器不会让你调整任何小于初始大小。 My workaround would be to set the initial CSS to a minimal width and height (whatever you think that should be, eg 50px or so); 我的解决方法是将初始CSS设置为最小宽度和高度(无论你认为应该是什么,例如50px左右); then use javascript to change the CSS of the div onload so that it is properly sized. 然后使用javascript更改div onload的CSS,使其大小合适。

See also HTML5 resize only on makes items larger than original size, not smaller . 另请参阅HTML5仅调整大小大于原始大小的项目,而不是更小

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM