Reputation: 81
Can someone help me with the following image gallery ?
I am trying to align all items inside a container with width 940px and the gallery div is 740 but I cannot figure out the technique and do it properly. May I ask some of you who are more experienced to explain to me how to structure the code and do it in proper way ?
Here is my code until this moment but almost everything is broken...
.container { position: relative; width: 940px; margin: 0 auto; }
.main { background: #f1f1e6; position: relative; }
.sidebar { display: block; width: 182px; float: left; padding: 41px 10px 10px 19px; }
.content { background: #fff; float: left; max-width: 740px; margin-top: 21px; overflow: hidden; box-shadow: 0 0 10px #99997a; }
.cf-me { clear: both; }
/* Content CSS Styles */
.sort-container { position: relative; left: 42.5%; }
.sort-items { position: relative; float: left; margin-top: 52px; }
.sort-items p { float: left; padding: 0 4px; }
.filter-products { position: absolute; left: 100%; font-size: 12px; line-height: 18px; color: #666651; background: #f2f2e7; border: 1px solid #e6e6cf; border-radius: 1px; padding: 2px 0; width: 160px; }
.product-label { display: block; float: left; }
.product-label h1 { position: relative; font-family: "Arial", sans-serif; font-size: 12px; font-weight: bold; padding: 15px 10px 16px 20px; }
.product-label h1:after { content:''; position: absolute; top: 0; border-bottom: 1px solid #e6e6cf; }
.product-label p { padding: 0 5px 15px 20px; }
.product-list { clear: both; }
.product-list ul { margin-right: -240px; }
.product-list ul li { list-style: none; float: left; width: 144px; margin: 0 48px 7px 50px; }
.product-list ul li img { max-width: 100%; height: auto; }
.product-list ul li a { color: #fff; }
.product-list ul li a:hover { opacity: 0.8; }
.btn { background: url(../images/btn-image.jpg) 0 0 no-repeat; }
.add-to-cart { font-family: "Arial", sans-serif; font-size: 14px; font-weight: bold; text-decoration: none; padding: 9px 33px 10px 9px; }
.left-arrow { float: left; width: 24px; height: 126px; }
.left-arrow a { display: block; height: 100%; background: url(../images/arrow.png) no-repeat 0 0; font-size: 0; line-height: 0; font-style: normal; overflow: hidden; text-indent: -100%; }
<main class="main">
<div class="paper-border"></div>
<div class="container">
<aside class="sidebar">
</aside><!-- sidebar -->
<div class="content">
<div class="product-label">
<h1>Products > Category Page</h1>
<p>Displaying 1-12 of 30 Product(s)</p>
</div><!-- product-label -->
<div class="sort-container">
<div class="sort-items">
<p>Sort By:</p>
<select class="filter-products">
<option value="default" selected>Default</option>
<option value="product_1">Product 1</option>
<option value="product_2">Product 2</option>
<option value="product_3">Product 3</option>
</select><!-- filter-products -->
</div><!-- sort-items -->
</div>
<div class="product-list">
<ul>
<li>
<div class="left-arrow">
<a href="#">left arrow</a>
</div>
<div class="item">
<a href="#" class="image"><img src="images/product_1.jpg" width="110" height="121" title="someText" alt="someText"></a>
<p class="title">Product Title<br>Placeholder</p>
<!-- /.title -->
<p class="price">$99.99</p><!-- /.price -->
<a href="#" class="btn add-to-cart">Add to Cart</a>
</div><!-- /.item -->
</li>
<li>
<div class="item">
<a href="#" class="image"><img src="images/product_2.jpg" width="138" height="87" title="someText" alt="someText"></a>
<p class="title">Product Title<br>Placeholder</p>
<!-- /.title -->
<p class="price">$99.99</p><!-- /.price -->
<a href="#" class="btn add-to-cart">Add to Cart</a>
</div><!-- /.item -->
</li>
<li>
<div class="item">
<a href="#" class="image"><img src="images/product_3.jpg" width="139" height="87" title="someText" alt="someText"></a>
<p class="title">Product Title<br>Placeholder</p>
<!-- /.title -->
<p class="price">$99.99</p><!-- /.price -->
<a href="#" class="btn add-to-cart">Add to Cart</a>
</div><!-- /.item -->
</li>
<li>
<div class="item">
<a href="#" class="image"><img src="images/product_4.jpg" width="160" height="160" title="someText" alt="someText"></a>
<p class="title">Product Title<br>Placeholder</p>
<!-- /.title -->
<p class="price">$99.99</p><!-- /.price -->
<a href="#" class="btn add-to-cart">Add to Cart</a>
</div><!-- /.item -->
</li>
<li>
<div class="left-arrow">
<a href="#">left arrow</a>
</div>
<div class="item">
<a href="#" class="image"><img src="images/product_5.jpg" width="123" height="136" title="someText" alt="someText"></a>
<p class="title">Product Title<br>Placeholder</p>
<!-- /.title -->
<p class="price">$99.99</p><!-- /.price -->
<a href="#" class="btn add-to-cart">Add to Cart</a>
</div><!-- /.item -->
</li>
<li>
<div class="item">
<a href="#" class="image"><img src="images/product_6.jpg" width="114" height="138" title="someText" alt="someText"></a>
<p class="title">Product Title<br>Placeholder</p>
<!-- /.title -->
<p class="price">$99.99</p><!-- /.price -->
<a href="#" class="btn add-to-cart">Add to Cart</a>
</div><!-- /.item -->
</li>
<li>
<div class="item">
<a href="#" class="image"><img src="images/product_7.jpg" width="127" height="133" title="someText" alt="someText"></a>
<p class="title">Product Title<br>Placeholder</p>
<!-- /.title -->
<p class="price">$99.99</p><!-- /.price -->
<a href="#" class="btn add-to-cart">Add to Cart</a>
</div><!-- /.item -->
</li>
<li>
<div class="item">
<a href="#" class="image"><img src="images/product_8.jpg" width="123" height="135" title="someText" alt="someText"></a>
<p class="title"Product Title<br>Placeholder</p>
<!-- /.title -->
<p class="price">$99.99</p><!-- /.price -->
<a href="#" class="btn add-to-cart">Add to Cart</a>
</div><!-- /.item -->
</li>
<li class="cf-me">
<div class="left-arrow">
<a href="#">left arrow</a>
</div>
<div class="item">
<a href="#" class="image"><img src="images/product_9.jpg" width="142" height="135" title="someText" alt="someText"></a>
<p class="title">Product Title<br>Placeholder</p>
<!-- /.title -->
<p class="price">$99.99</p><!-- /.price -->
<a href="#" class="btn add-to-cart">Add to Cart</a>
</div><!-- /.item -->
</li>
<li>
<div class="item">
<a href="#" class="image"><img src="images/product_10.jpg" width="75" height="140" title="someText" alt="someText"></a>
<p class="title">Product Title<br>Placeholder</p>
<!-- /.title -->
<p class="price">$99.99</p><!-- /.price -->
<a href="#" class="btn add-to-cart">Add to Cart</a>
</div><!-- /.item -->
</li>
<li>
<div class="item">
<a href="#" class="image"><img src="images/product_11.jpg" width="75" height="129" title="someText" alt="someText"></a>
<p class="title">Product Title<br>Placeholder</p>
<!-- /.title -->
<p class="price">$99.99</p><!-- /.price -->
<a href="#" class="btn add-to-cart">Add to Cart</a>
</div><!-- /.item -->
</li>
<li>
<div class="item">
<a href="#" class="image"><img src="images/product_12.jpg" width="136" height="122" title="someText" alt="someText"></a>
<p class="title">Product Title<br>Placeholder</p>
<!-- /.title -->
<p class="price">$99.99</p><!-- /.price -->
<a href="#" class="btn add-to-cart">Add to Cart</a>
</div><!-- /.item -->
</li>
</ul>
</div><!-- content -->
</div><!-- container -->
Upvotes: 0
Views: 46
Reputation: 230
If you want the gallery content to expand out to the 940px size you'll need to update the following line of code to max-width: 940px
:
.content { background: #fff; float: left; max-width: 740px; margin-top: 21px; overflow: hidden; box-shadow: 0 0 10px #99997a; }
That will only resolve the size issue a bit though. At that point you'll have margin issues and a breakdown of elements based on your tags floats
and the widths
that the code defines for each DIV
I did some light tinkering of your code and added in some images from placehold.it to try and see if I got what you're looking for. Take a look at the link below and let me know.
Upvotes: 1