The code below works fine at 1280x800, however, if I add another thumbnail, the width of the <ul>
becomes equal to the <body>
width and <ul>
isn't centered anymore. I don't want to specify the <ul>
width, which would solve the problem. I want thumbnails to occupy all free space regardless of resolution, but at the same time having equal margins on the left and right. Is there any pure CSS way of doing this without calculating the <ul>
's width in JavaScript each time the page loads or using CSS3 media queries?
<html>
<head>
<title>Gallery</title>
<style type="text/css" media="screen">
body {
text-align: center;
}
ul {
padding: 0;
display: inline-block;
list-style-type: none;
}
li {
float: left;
width: 200px;
background-color: violet;
}
</style>
</head>
<body>
<ul>
<li>thumbnail</li>
<li>thumbnail</li>
<li>thumbnail</li>
<li>thumbnail</li>
<li>thumbnail</li>
<li>thumbnail</li>
</ul>
</body>