开发者

get div current (rendered) width with javascript

Hey, Ive got an php script dragging some images from a database and displaying them using float:left; so they go left to right.

However unless in the css i define i width for the container they jump down onto a 2nd line.

So the question IS!

How for the life of me could I get it to fi开发者_如何学运维gure out the width of the content and then set the width attribute via javascript all on the one load.

I did have a slight worry that this wouldnt be easily possible as it wud have had to render the images/layout first to get a width before then adjusting it.

Ideas please people!! x


Your question has to do with how the flows of floats work...

If two images are floated and the sum of their widths is wider than the containing element, they will wrap (similar to the way words in a paragraph wrap).

Visual references describing the flow of "float"ed elements (way too difficult to describe in a few words):

  • http://css.maxdesign.com.au/floatutorial/introduction.htm
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜