Jump to content

automatic div width


scotto

Recommended Posts

Is there a way to define a generic div container so its width is dictated by an image placed inside it?For example:CSS

div.mydiv {...}

HTML

...<div class="mydiv">  <img src="myimage" />  ...</div>...

So, say my image was 340px wide, that would be the width of the div. The idea being, if the div also contained text, that text would wrap, and stay within the bounds of the images width. Maybe handy for displaying images with captions.I want to avoid making custom div's of specific widths.Thanks,Scott

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...