使用CSS调整< div>到小于其当前宽度和高度的尺寸 [英] Using CSS to resize a <div> to a dimension smaller than its current width and height

查看:137
本文介绍了使用CSS调整< div>到小于其当前宽度和高度的尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个div,其css看起来像这样:

I currently have a div whose css looks like this:

.class
{
overflow:auto;
resize: both;
width: 100px;
height: 100px;
}



我希望用户能够调整div的大小,并且高度可以小于100像素。这是怎么回事?

I want the user to be able to resize the div so that the resulting width and height can be less than 100px. How is this possible?

编辑:一些上下文。我想要这个功能,因为我正在开发一个应用程序,用户可以调整窗口小部件的大小,并将此宽度和高度保存到服务器,以便在会话之间保存大小。因为它是当前设置,当用户停止调整大小,我的代码重新设置div的宽度和高度属性动态。它工作伟大,如果用户正在使div更大。然而,用户不能使div任何更小。

Some context. I want this feature because I am developing an application where a user can resize a widget and saves this width and height to a server so that the size is saved across sessions. As it is currently setup, when the user stops resizing, my code resets the div's width and height properties dynamically. It works great if the user is making the div larger. However the user cannot then make the div any smaller.

EDIT2:我使用GWT开发此应用程序。更具体地说,这个div只是一个AbsolutePanel。

I am using GWT to develop this application. More specifically, this div is just an AbsolutePanel.

推荐答案

问题有点模糊,不能只是制作面板 LayoutPanel

The question is a little vague, can't you just make the panel a LayoutPanel?

使用 DOM客户端软件包。具体来说, getHeight() setHeight() getWidth() setWidth()

Get/set the height and width with the Style methods of the DOM client package. Specifically, getHeight(), setHeight(), getWidth(), and setWidth().

这篇关于使用CSS调整< div>到小于其当前宽度和高度的尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆