确定< div>的高度和宽度。动态 [英] Determining the height and width of a <div> dynamically

查看:71
本文介绍了确定< div>的高度和宽度。动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!


我创建了一条消息由< div>组成的框其中包含一堆信息和一些按钮(可以是ok,yes,no,取消......)。它是在服务器上使用一些.NET代码动态创建的。


因为此< div>中的消息信息是动态的,它可以是几行...也是消息框< div>也可以是宽度可变的宽度。因此,我需要一种可靠的方法来动态检索< div>的宽度和高度。为了正确地将它放在浏览器的中间。


我用过:

Hi there!

I''ve created a "message" box that consists of a <div> with a bunch of information in it and some buttons (which could be "ok", "yes", "no", "cancel"...). It''s dynamically created with some .NET code on the server.

Because the message information that is within this <div> is dynamic, it can be several lines long...also the message box <div> can be variable widths wide as well. Therefore, I need a Dependable way to dynamically retrieve the width and height of the <div> in order to properly center it in the middle of the browser.

I have used:

展开 | 选择 | 换行 | 行号

推荐答案

嗨frinny,


看看这个主题有帮助...这里是另一个链接;)


亲切的问候
hi frinny,

have a look whether this thread helps ... and here is another link ;)

kind regards



嗨frinny,


看看这个帖子有帮助...这里是另一个链接;)


亲切的问候
hi frinny,

have a look whether this thread helps ... and here is another link ;)

kind regards



谢谢Gits,

我现在正在调查offsetHeight和offsetWidth。

我想我之前已经尝试过了,如果有帮助,我会尽快通知你。



-Frinny

Thanks Gits,
I''m looking into the offsetHeight and offsetWidth now.
I think I''ve tried this before, I''ll get back to you to let you know if it helps.


-Frinny



谢谢Gits,

我'我现在正在调查offsetHeight和offsetWidth。

我想我之前已经尝试过了,如果有帮助,我会回复你,让你知道。



-Frinny
Thanks Gits,
I''m looking into the offsetHeight and offsetWidth now.
I think I''ve tried this before, I''ll get back to you to let you know if it helps.


-Frinny



offsetHeight和offsetWidth不起作用。

The offsetHeight and offsetWidth did not work.


这篇关于确定&lt; div&gt;的高度和宽度。动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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