Grow your CSS skills. Land your dream job.

css help with dynamic image size

  • # January 28, 2013 at 11:28 am

    [Your text to link here...](http://www.hartstikkide.be/temp/css.jpg “image”)

    (see linked image)
    I have problems with my (css-)layout.
    I have an outer box > no fixed width > has to follow te inner image-width
    I have 2 inner boxes > the first contains the image
    The second contains some text > the width of this box > must be the same width as the image

    Any advise / tips ???

    THX
    Koen

    # January 28, 2013 at 11:44 am

    Unless your images are of a consistent width you are going to end up with a series of stacked boxes with random widths.

    Would it not be better to set a width for the container and have the images adapt to that?

    # January 28, 2013 at 11:58 am

    you could do something like [This...](http://codepen.io/anon/pen/zdDLE “This…”)
    that example will set the width of the outer box by checking the .image class inside of it.

    # January 28, 2013 at 12:20 pm

    That works quite nicely (with a little tweaking): http://codepen.io/anon/pen/ywbGH

    I have zero JS skills so I’m sure it could be improved and the structure/CSS simplified.

    # January 28, 2013 at 1:28 pm

    Paulie / Carl.
    Thx for the answers > I’ll check it out !

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".