CSS Width

devongovett

New Member
Messages
33
Reaction score
0
Points
0
Hello,

I would like to set the width of an html element to be 100% of the width of its contents. This will mean that it will be bigger than its parent element.

Here is the html:

Code:
<div id="items">
    <ul>
        <li><img src="sample.png"></li>
        <li><img src="image.jpg"></li>
        ...
    </ul>
</div>

And the CSS:

Code:
#items{
    width: 100%; //full browser window
    overflow: hidden;
}
 
#items ul li{
    list-style-type: none;
    float: left;
    margin-right: 20px;
}
 
#items ul{
    //I want the width of this element to be the full width 
    of all of the images in the list, no matter how wide the 
    parent element is.  Right now the images wrap to a 
    new line.
}

Can I do this with CSS, or do I have to use Javascript/jQuery?

Thanks for your help!
Devon
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
A child cannot be bigger than it's parent... sorry!
 
Top