Simple html/css ecommerce product grid with a hover effect.
Created
April 20, 2019 16:52
-
-
Save jegazhu/dcb2bd22446276c5005206d2eae02b4d to your computer and use it in GitHub Desktop.
Ecommerce product list/grid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="wrapper"> | |
<div class="desc"> | |
<h1>Ecommerce product list/grid</h1> | |
<p>Simple html/css ecommerce product grid with a hover effect.</p> | |
<div class="todo"> | |
<span>TODO list:</span> | |
<ul> | |
<li>Make it responsive folk!</li> | |
</ul> | |
</div> | |
</div> | |
<div class="content"> | |
<!-- content here --> | |
<div class="product-grid product-grid--flexbox"> | |
<div class="product-grid__wrapper"> | |
<!-- Product list start here --> | |
<!-- Single product --> | |
<div class="product-grid__product-wrapper"> | |
<div class="product-grid__product"> | |
<div class="product-grid__img-wrapper"> | |
<img src="https://images.apple.com/euro/macbook/a/screens/specs/images/finish_silver_large.jpg" alt="Img" class="product-grid__img" /> | |
</div> | |
<span class="product-grid__title">Product title</span> | |
<span class="product-grid__price">1.399€</span> | |
<div class="product-grid__extend-wrapper"> | |
<div class="product-grid__extend"> | |
<p class="product-grid__description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis velit itaque odit.</p> | |
<span class="product-grid__btn product-grid__add-to-cart"><i class="fa fa-cart-arrow-down"></i> Add to cart</span> | |
<span class="product-grid__btn product-grid__view"><i class="fa fa-eye"></i> View more</span> | |
</div> | |
</div> | |
</div> | |
</div> | |
<!-- end Single product --> | |
<div class="product-grid__product-wrapper"> | |
<div class="product-grid__product"> | |
<div class="product-grid__img-wrapper"> | |
<img src="https://images.apple.com/euro/macbook/a/screens/specs/images/finish_silver_large.jpg" alt="Img" class="product-grid__img" /> | |
</div> | |
<span class="product-grid__title">Product title</span> | |
<span class="product-grid__price">1.399€</span> | |
<div class="product-grid__extend-wrapper"> | |
<div class="product-grid__extend"> | |
<p class="product-grid__description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis velit itaque odit.</p> | |
<span class="product-grid__btn product-grid__add-to-cart"><i class="fa fa-cart-arrow-down"></i> Add to cart</span> | |
<span class="product-grid__btn product-grid__view"><i class="fa fa-eye"></i> View more</span> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="product-grid__product-wrapper"> | |
<div class="product-grid__product"> | |
<div class="product-grid__img-wrapper"> | |
<img src="https://images.apple.com/euro/macbook/a/screens/specs/images/finish_silver_large.jpg" alt="Img" class="product-grid__img" /> | |
</div> | |
<span class="product-grid__title">Product title</span> | |
<span class="product-grid__price">1.399€</span> | |
<div class="product-grid__extend-wrapper"> | |
<div class="product-grid__extend"> | |
<p class="product-grid__description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis velit itaque odit.</p> | |
<span class="product-grid__btn product-grid__add-to-cart"><i class="fa fa-cart-arrow-down"></i> Add to cart</span> | |
<span class="product-grid__btn product-grid__view"><i class="fa fa-eye"></i> View more</span> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="product-grid__product-wrapper"> | |
<div class="product-grid__product"> | |
<div class="product-grid__img-wrapper"> | |
<img src="https://images.apple.com/euro/macbook/a/screens/specs/images/finish_silver_large.jpg" alt="Img" class="product-grid__img" /> | |
</div> | |
<span class="product-grid__title">Product title</span> | |
<span class="product-grid__price">1.399€</span> | |
<div class="product-grid__extend-wrapper"> | |
<div class="product-grid__extend"> | |
<p class="product-grid__description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis velit itaque odit.</p> | |
<span class="product-grid__btn product-grid__add-to-cart"><i class="fa fa-cart-arrow-down"></i> Add to cart</span> | |
<span class="product-grid__btn product-grid__view"><i class="fa fa-eye"></i> View more</span> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="product-grid__product-wrapper"> | |
<div class="product-grid__product"> | |
<div class="product-grid__img-wrapper"> | |
<img src="https://images.apple.com/euro/macbook/a/screens/specs/images/finish_silver_large.jpg" alt="Img" class="product-grid__img" /> | |
</div> | |
<span class="product-grid__title">Product title</span> | |
<span class="product-grid__price">1.399€</span> | |
<div class="product-grid__extend-wrapper"> | |
<div class="product-grid__extend"> | |
<p class="product-grid__description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis velit itaque odit.</p> | |
<span class="product-grid__btn product-grid__add-to-cart"><i class="fa fa-cart-arrow-down"></i> Add to cart</span> | |
<span class="product-grid__btn product-grid__view"><i class="fa fa-eye"></i> View more</span> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="product-grid__product-wrapper"> | |
<div class="product-grid__product"> | |
<div class="product-grid__img-wrapper"> | |
<img src="https://images.apple.com/euro/macbook/a/screens/specs/images/finish_silver_large.jpg" alt="Img" class="product-grid__img" /> | |
</div> | |
<span class="product-grid__title">Product title</span> | |
<span class="product-grid__price">1.399€</span> | |
<div class="product-grid__extend-wrapper"> | |
<div class="product-grid__extend"> | |
<p class="product-grid__description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis velit itaque odit.</p> | |
<span class="product-grid__btn product-grid__add-to-cart"><i class="fa fa-cart-arrow-down"></i> Add to cart</span> | |
<span class="product-grid__btn product-grid__view"><i class="fa fa-eye"></i> View more</span> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="product-grid__product-wrapper"> | |
<div class="product-grid__product"> | |
<div class="product-grid__img-wrapper"> | |
<img src="https://images.apple.com/euro/macbook/a/screens/specs/images/finish_silver_large.jpg" alt="Img" class="product-grid__img" /> | |
</div> | |
<span class="product-grid__title">Product title</span> | |
<span class="product-grid__price">1.399€</span> | |
<div class="product-grid__extend-wrapper"> | |
<div class="product-grid__extend"> | |
<p class="product-grid__description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis velit itaque odit.</p> | |
<span class="product-grid__btn product-grid__add-to-cart"><i class="fa fa-cart-arrow-down"></i> Add to cart</span> | |
<span class="product-grid__btn product-grid__view"><i class="fa fa-eye"></i> View more</span> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="product-grid__product-wrapper"> | |
<div class="product-grid__product"> | |
<div class="product-grid__img-wrapper"> | |
<img src="https://images.apple.com/euro/macbook/a/screens/specs/images/finish_silver_large.jpg" alt="Img" class="product-grid__img" /> | |
</div> | |
<span class="product-grid__title">Product title</span> | |
<span class="product-grid__price">1.399€</span> | |
<div class="product-grid__extend-wrapper"> | |
<div class="product-grid__extend"> | |
<p class="product-grid__description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis velit itaque odit.</p> | |
<span class="product-grid__btn product-grid__add-to-cart"><i class="fa fa-cart-arrow-down"></i> Add to cart</span> | |
<span class="product-grid__btn product-grid__view"><i class="fa fa-eye"></i> View more</span> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="product-grid__product-wrapper"> | |
<div class="product-grid__product"> | |
<div class="product-grid__img-wrapper"> | |
<img src="https://images.apple.com/euro/macbook/a/screens/specs/images/finish_silver_large.jpg" alt="Img" class="product-grid__img" /> | |
</div> | |
<span class="product-grid__title">Product title</span> | |
<span class="product-grid__price">1.399€</span> | |
<div class="product-grid__extend-wrapper"> | |
<div class="product-grid__extend"> | |
<p class="product-grid__description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis velit itaque odit.</p> | |
<span class="product-grid__btn product-grid__add-to-cart"><i class="fa fa-cart-arrow-down"></i> Add to cart</span> | |
<span class="product-grid__btn product-grid__view"><i class="fa fa-eye"></i> View more</span> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<footer> | |
<a target="_blank" href="https://twitter.com/ricardpanades">@ricardpanades</a> | |
</footer> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.wrapper { | |
width: 68em; | |
} | |
// Start here | |
$title-color: #222; | |
$font-color: #777; | |
$light-gray: #eee; | |
$primary: #E91E63; | |
$secondary: #42A5F5; | |
// product | |
$product-box-shadow: 0px 0px 0px 1px $light-gray; | |
* { | |
box-sizing: border-box; | |
} | |
body { | |
color: $font-color; | |
font-family: 'Open Sans', Arial, sans-serif; | |
} | |
.product-grid { | |
width: 60em; | |
margin: 2rem auto; | |
// TODO: apply clearfix | |
// If want a flexbox grid. | |
&.product-grid--flexbox { | |
.product-grid__wrapper { | |
display: flex; | |
flex-wrap: wrap; | |
} | |
.product-grid__title { | |
height: auto; | |
&:after { display: none; } | |
} | |
} | |
&__wrapper { | |
margin-left: -1rem; | |
margin-right: -1rem; | |
//background: #000; | |
} | |
&__product-wrapper { | |
padding: 1rem; | |
float: left; | |
width: 33.33333%; | |
} | |
&__product { | |
padding: 1rem; | |
// width: 33.33333%; | |
// float: left; | |
position: relative; | |
cursor: pointer; | |
background: #fff; | |
//box-shadow: $product-box-shadow; | |
border-radius: 4px; | |
&:hover { | |
box-shadow: $product-box-shadow; | |
z-index: 50; | |
.product-grid__extend { | |
display: block; | |
} | |
} | |
} | |
// product image wrapper | |
&__img-wrapper { | |
width: 100%; | |
text-align: center; | |
padding-top: 1rem; | |
padding-bottom: 1rem; | |
height: 150px; | |
} | |
// product image | |
&__img { | |
max-width: 100%; | |
height: auto; | |
max-height: 100%; | |
} | |
// product title | |
&__title { | |
margin-top: .875rem; | |
display: block; | |
font-size: 1.125em; | |
color: $title-color; | |
height: 3em; | |
overflow: hidden; | |
position: relative; | |
&:after { | |
content: ""; | |
display: block; | |
position: absolute; | |
bottom: 0; | |
right: 0; | |
width: 2.4em; | |
height: 1.5em; // magic number | |
background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 50%); | |
//background: red; | |
} | |
} | |
&__price { | |
color: $primary; | |
font-weight: bold; | |
letter-spacing: .4px; | |
} | |
// extend wrapper | |
&__extend-wrapper { | |
position: relative; | |
} | |
// extended elements | |
// show when hover .product-grid__product | |
&__extend { | |
display: none; | |
position: absolute; | |
padding: 0 1rem 1rem 1rem; | |
margin: .4375rem -1rem 0; | |
box-shadow: $product-box-shadow; | |
background: #fff; | |
border-radius: 0 0 4px 4px; | |
&:before { | |
content: ""; | |
height: .875rem; | |
width: 100%; | |
position: absolute; | |
top: -.4375rem; | |
left: 0; | |
background: #fff; | |
} | |
} | |
// product description | |
&__description { | |
font-size: .875em; | |
//margin-top: .875rem; | |
margin-top: .4375rem; | |
margin-bottom: 0; | |
} | |
// buttons | |
&__btn { | |
display: inline-block; | |
font-size: .875em; | |
color: $font-color; | |
background: $light-gray; | |
padding: .5em .625em; | |
margin-top: .875rem; | |
margin-right: .625rem; | |
cursor: pointer; | |
border-radius: 4px; | |
i.fa { margin-right: .3125rem;} | |
} | |
&__add-to-cart { | |
color: #fff; | |
background: $primary; | |
&:hover { background: lighten($primary, 10%); } | |
} | |
&__view { | |
color: $font-color; | |
background: $light-gray; | |
&:hover { background: lighten($light-gray, 10%); } | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://codepen.io/ricardpanades/pen/WvJxGv" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment