Reputation: 633
<ul id='ul01'>
<li><a href='#'><img src='img01.png' width="700" height="590" /></a></li>
<li><a href='#'><img src='img02.png' width="700" height="590" /></a></li>
<li><a href='#'><img src='img03.png' width="700" height="590" /></a></li>
</ul>
CSS:
#ul01{list-style:none;width:??;}
#ul01 li{float:left;}
This is a horizontal array of images. list.items.count can vary.
What should be the width property to fit all images.
I tried with - auto - and expected resizible width - but it's not.
Upvotes: 11
Views: 37619
Reputation: 26386
if your images have to retain the sizes you specified then know that your page will have horizontal scrollbar. If you prefer that this will work
#ul01{list-style:none;width:2100px;}
#ul01 li{float:left; width:700px}
The ul
width has to be the (width X 3) + (2 X image-border-if-any} + padding
= 2100px + n
Upvotes: 1
Reputation: 937
Make the li
elements inline-block
s and set the white-space
property of the ul
to nowrap
.
li {
display: inline-block;
}
ul {
white-space: nowrap;
}
Upvotes: 15
Reputation: 3657
Make these change i think these will work for you...
#ul01{list-style:none;width:100%;}
#ul01 li{float:left; width:33%; }
#ul01 li a { display:block; }
#ul01 li a img { width:100%; height:auto; }
<ul id='ul01'>
<li><a href='#'><img src='img01.png' /></a></li>
<li><a href='#'><img src='img02.png' /></a></li>
<li><a href='#'><img src='img03.png' /></a></li>
</ul>
Upvotes: 2
Reputation: 1189
try jquery, so in css file you can put 0, and value would be change later.
<script type="text/javascript">
$(document).ready(function () {
var sum = 0;
$('#ul01 li img').each(function() {
sum += parseInt($(this).attr("width"), 10);
});
$('#ul01').css({ 'width': sum+'px' });
});
</script>
Upvotes: 0