DIV Width Match Content

Discussion in 'HTML' started by ekazda, Feb 13, 2008.

  1. ekazda

    ekazda Guest

    Okay, I know this can't be that hard... or can it? :stupido:

    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):

    ------

    LABEL
    DIV
    FILE UPLOAD

    ------

    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:

    ------

    LABEL DIV
    FILE UPLOAD

    ------

    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).
    ekazda, Feb 13, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AndrewF
    Replies:
    1
    Views:
    744
    Bruce Barker
    Oct 10, 2005
  2. Replies:
    0
    Views:
    504
  3. Stan R.
    Replies:
    2
    Views:
    20,622
    Spartanicus
    Apr 1, 2006
  4. =?Utf-8?B?cm9kY2hhcg==?=

    how to: div width = browser.width?

    =?Utf-8?B?cm9kY2hhcg==?=, Oct 27, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    512
    =?Utf-8?B?cm9kY2hhcg==?=
    Oct 30, 2006
  5. Steve Richter
    Replies:
    2
    Views:
    7,891
    Steve Richter
    Jun 15, 2007
Loading...

Share This Page