div CSS Width Setting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PlexusMaldon
    New Member
    • Nov 2006
    • 8

    div CSS Width Setting

    Hi, I have a question about setting the widths of divs with CSS that I have a feeling will be answered simply with a "no".

    I have some divs that I want to have conform to the right hand side of their content but I don't want to arbitrarily set their widths to a set measurement or percentage. However if I don't specify a width it defaults to 100% of the page width. Is there any way I can set the width to automatically shrink to that of the content?

    Cheers

    Phil
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    Yes, the answer is no.

    Comment

    • PlexusMaldon
      New Member
      • Nov 2006
      • 8

      #3
      Originally posted by drhowarddrfine
      Yes, the answer is no.
      Thought so, thanks for that.

      If anyone has found a neat way of doing this is CSS rather than having to go back to tables, I'd appreciate an overview, and if I work out an alternative I'll post it here.

      Cheers

      Phil

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        In what way does tables do that without setting a width?

        Comment

        • PlexusMaldon
          New Member
          • Nov 2006
          • 8

          #5
          Originally posted by drhowarddrfine
          In what way does tables do that without setting a width?
          I'm referring to the effect you can get with a table with the border set to 0 and a background colour so that if its width is less than the page width it will only take up however much room it actually requires, and no more, so it looks like a "frame". As I'm moving to CSS, I don't want to (ab)use tables for these sort of layout purposes any more.

          Comment

          • drhowarddrfine
            Recognized Expert Expert
            • Sep 2006
            • 7434

            #6
            I'm not sure I'm correctly picturing what you want to do. Do you have a screenshot or link? I think you can do what I think you want.

            Comment

            • PlexusMaldon
              New Member
              • Nov 2006
              • 8

              #7
              Originally posted by drhowarddrfine
              I'm not sure I'm correctly picturing what you want to do. Do you have a screenshot or link? I think you can do what I think you want.
              Is it possible to upload local images to this server (I'm guessing not as the IMG tag looks like it only serves online images) as I don't have anywhere I can load images up to, to create links to?

              Comment

              Working...