Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > DIV Width Match Content

Thread Tools

DIV Width Match Content

Posts: n/a
Okay, I know this can't be that hard... or can it?

What I have are three elements within a custom CMS (I'm using some .net objects, but that doesn't matter in regards to what I am trying to do):




I'm using the DIV to return information regarding any current image that may already exist on the server. If no image exists, I simply hide the DIV. If an image does exist, I display the DIV.

NOW, this DIV is style to have a nice border, some padding, and a pretty BG color. What I would like to do is SNAP THE WIDTH of the DIV to match the CONTENT (a hyperlink).

Using DISPLAY:INLINE snaps the width to the content PERFECTLY. However, it makes the layout change to the following:




That's no good.

Without DISPLAY:INLINE, the DIV stretches to match its container, which is 100%.

SO, the question is how do I maintain the BLOCK characteristics of the DIV, but simply snap the width to the content (WITHOUT JAVASCRIPT).
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
set div width to remaining width of the browser Steve Richter ASP .Net 2 06-15-2007 06:40 PM
how to: div width = browser.width? =?Utf-8?B?cm9kY2hhcg==?= ASP .Net 3 10-30-2006 05:43 AM
possible to make div width match content? Stan R. HTML 2 04-01-2006 04:27 PM
Cell width error when containing variable width content HTML 0 01-26-2006 03:37 PM
Textbox width scaling to width of data not width of page? AndrewF ASP .Net 1 10-10-2005 04:38 PM