I'm having trouble to make the content scroll in smaller viewport even with overflow property. My goal is to maintain the size of each image box and with the ability to scroll horizontally when the viewport is minimized.
.block-content {
width: 100%;
height: 100%;
}
.block-content .even-content {
display: flex;
position: relative;
width: 100%;
margin: 0 auto;
overflow: auto;
white-space: nowrap;
}
.even-content>* {
flex: 1;
}
.container {
position: relative;
overflow: hidden;
height: 100%;
width: 100%;
}
.image {
width: 100%;
height: 100%;
transition: all .5s ease;
object-fit: cover;
object-position: center;
}
.card-text {
padding: 3.75rem;
position: absolute;
z-index: 1;
left: 0;
bottom: 0;
}
.card-text h3 {
color: white;
margin-bottom: 2rem;
font-size: 2.25rem;
}
.card-text .fa-arrow-right {
margin-right: 10px;
}
.container:hover .image {
transform: scale(1.03);
}
<section class="block-content">
<div class="even-content scroll-menu">
<div class="container">
<img src="https://cdn.shopify.com/s/files/1/0598/5071/9391/files/homepage_update_september_23_04_900x.png?v=1663942261 alt=" " class="image ">
<div class="card-text ">
<h3>Pack Heavy <br><i class="fa-solid fa-arrow-right "></i>Chase Light</h3>
<button class="button ">Watch Now</button>
</div>
</div>
<div class="container ">
<img src="https://cdn.shopify.com/s/files/1/0598/5071/9391/files/homepage_us_au_mid_august_04_900x.png?v=1660903200 " alt=" " class="image ">
<div class="card-text ">
<h3>Midnight Sun</h3>
<button class="button ">Shop</button>
</div>
</div>
<div class="container ">
<img src="https://cdn.shopify.com/s/files/1/0598/5071/9391/files/homepage_update_september_23_05_ecfb361d-bd54-4d01-b9f1-0669bfd82552_900x.png?v=1663943416 " alt=" " class="image ">
<div class="card-text ">
<h3>SS22</h3>
<button class="button ">Shop</button>
</div>
</div>
</div>
</section>
Return to post
Your issue comes from this block:
.even-content>* {
flex: 1;
}
flex is a shorthand for the following CSS properties:
flex-grow
flex-shrink
flex-basis
Those blocks are similar:
.even-content>* {
flex: 1;
}
.even-content>* {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 0%;
}
So, what is happening?
flex-shrink
The flex-shrink CSS property sets the flex shrink factor of a flex item. If the size of all flex items is larger than the flex container, items shrink to fit according to flex-shrink.
flex-shrink - MDN
You're telling your .even-content>* that they should shrink without having a minimum width.
What can you do?
You can add a flex-basis with the minimum width you're willing to have and change your flex-shrink property to 0.
.even-content>* {
flex: 1 0 320px;
}
Full code:
.block-content {
width: 100%;
height: 100%;
}
.block-content .even-content {
display: flex;
position: relative;
width: 100%;
margin: 0 auto;
overflow: auto;
white-space: nowrap;
}
.even-content>* {
flex: 1 0 320px;
}
.container {
position: relative;
overflow: hidden;
height: 100%;
width: 100%;
}
.image {
width: 100%;
height: 100%;
transition: all .5s ease;
object-fit: cover;
object-position: center;
}
.card-text {
padding: 3.75rem;
position: absolute;
z-index: 1;
left: 0;
bottom: 0;
}
.card-text h3 {
color: white;
margin-bottom: 2rem;
font-size: 2.25rem;
}
.card-text .fa-arrow-right {
margin-right: 10px;
}
.container:hover .image {
transform: scale(1.03);
}
<section class="block-content">
<div class="even-content scroll-menu">
<div class="container">
<img src="https://cdn.shopify.com/s/files/1/0598/5071/9391/files/homepage_update_september_23_04_900x.png?v=1663942261" alt=" " class="image ">
<div class="card-text ">
<h3>Pack Heavy <br>
<i class="fa-solid fa-arrow-right "></i>Chase Light
</h3>
<button class="button ">Watch Now</button>
</div>
</div>
<div class="container ">
<img src="https://cdn.shopify.com/s/files/1/0598/5071/9391/files/homepage_us_au_mid_august_04_900x.png?v=1660903200
" alt=" " class="image ">
<div class="card-text ">
<h3>Midnight Sun</h3>
<button class="button ">Shop</button>
</div>
</div>
<div class="container ">
<img src="https://cdn.shopify.com/s/files/1/0598/5071/9391/files/homepage_update_september_23_05_ecfb361d-bd54-4d01-b9f1-0669bfd82552_900x.png?v=1663943416
" alt=" " class="image ">
<div class="card-text ">
<h3>SS22</h3>
<button class="button ">Shop</button>
</div>
</div>
</div>
</section>
Return to post
Related
How do I make my image gets centered in the .s-circles-1 <div>...
Html
.s-circles-1 {
display: inline-block;
opacity: 0.1;
margin-left: 315px;
margin-top: 155px;
background-color: #fff;
width: 164px;
height: 164px;
border-radius: 100%;
position: relative;
}
.s-img-1 {
opacity: 0.9;
display: inline-block;
position: absolute;
color: #E37218;
margin-right: 70vw;
width: 120px;
height: 120px;
}
<div class="services">
<div class="s-text">
<h2>Services</h2>
</div>
<div class="s-circles-1">
<img src="/Shapes/code (1).svg" alt="" class="s-img-1">
</div>
</div>
I am trying to make my image get inserted in the circle.
Thanks in advance.
With background-image :
div.circle {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
border-radius: 100%;
width: 164px;
aspect-ratio : 1 / 1;
}
<div class="services">
<div class="s-text">
<h2>Services</h2>
</div>
<div class="circle" style="background-image: url(https://thispersondoesnotexist.com/image)"></div>
</div>
With your code, you need to change your css with this (if you don't want to use background-image) :
s-circles-1 class : set overflow:hidden;
s-img-1 class : set
width:100%; and height:100%;
.s-circles-1 {
display: inline-block;
opacity: 0.5;
width: 164px;
aspect-ratio:1 / 1; /* Keep the same width */
border-radius: 100%;
overflow: hidden;
}
.s-circles-1 img {
opacity: 0.9;
width: 100%;
height: 100%;
}
<div class="services">
<div class="s-text">
<h2>Services</h2>
</div>
<div class="s-circles-1">
<img src="https://thispersondoesnotexist.com/image" alt="">
</div>
</div>
With your code, but if your image is not a square :
div.circle {
display: flex;
justify-content: center;
align-items: center;
border-radius: 100%;
width: 164px;
aspect-ratio : 1 / 1;
overflow: hidden;
}
div.circle img {
/*if width > height*/
height: 164px;
/*if height > width*/
/*width: 164px;*/
}
<div class="services">
<div class="s-text">
<h2>Services</h2>
</div>
<div class="circle">
<img src="https://dummyimage.com/1200x500/000/fff" alt="" class="circle">
</div>
</div>
I created a hover effect that is blurring out a picture and a text-description appears.
Now as soon as I hover above the description, I dont hover the image and the effect is failing, which I would like to prevent.
I assume that if I could target the hovered - version of the description, I could make it set sort of itself to be visible, but I am not sure about this.
Any other ideas how I can create this?
.flexbox{
position: relative;
display: flex;
height: 70vh;
flex-direction: row;
width: 90%;
margin-left: 5%;
max-height: 80vh;
}
.container{
width: 100%;
max-height: inherit;
padding: 0;
margin: 1%;
display:block;
text-align: center;
}
.image-category{
width: 100%;
object-fit: cover;
height: 100%;
opacity: 0.95;
max-height: inherit;
overflow: hidden;
}
.image-description{
padding: 10px;
transform: translateY(-30vh);
opacity: 0;
z-index: -1;
font-size: 20px;
}
.image-category:hover{
filter: blur(2px);
}
.image-category:hover ~ .image-description{
opacity: 100;
z-index: 2;
}
.description{
font-size: 1.25em;
background: rgba(255, 255, 255, 0.7);
}
.claim{
padding: 1vh 0 1vh 0;
width: 100%;
text-align: center;
}
Delay Hover
<div class="flexbox" id="flex">
<div class="container" id="box1">
<a class="image-category" href="https://amh-solingen.de/scheren.html">
<img class="image-category" id="product3" src="/images/Schere.jpg">
</a>
<div class="image-description">
<p class="description">Haushalts- und Friseurscheren</p>
</div>
</div>
<div class="container" id="box2">
<a class="image-category" href="https://amh-solingen.de/haushaltsmesser.html">
<img class="image-category" id="product2" src="/images/Hero.png">
</a>
<div class="image-description">
<p class="description">Aktuelle Auswahl an Küchenmessern</p>
</div>
</div>
<div class="container" id="box3">
<a class="image-category" href="https://amh-solingen.de/klingen.html">
<img class="image-category" id="product3" src="/images/Klinge_7.jpg">
</a>
<div class="image-description">
<p class="description">Klingen für Haushaltsmesser</p>
</div>
</div>
</div>
use this code:
.flexbox{
position: relative;
display: flex;
height: 70vh;
flex-direction: row;
width: 90%;
margin-left: 5%;
max-height: 80vh;
}
.container{
width: 100%;
max-height: inherit;
padding: 0;
margin: 1%;
display:block;
text-align: center;
}
.image-category{
width: 100%;
object-fit: cover;
height: 100%;
opacity: 0.95;
max-height: inherit;
overflow: hidden;
}
.image-description{
padding: 10px;
transform: translateY(-30vh);
opacity: 0;
z-index: -1;
font-size: 20px;
}
.container:hover .image-category{
filter: blur(2px);
}
.container:hover .image-description{
opacity: 100;
z-index: 2;
}
.description{
font-size: 1.25em;
background: rgba(255, 255, 255, 0.7);
}
.claim{
padding: 1vh 0 1vh 0;
width: 100%;
text-align: center;
}
Delay Hover
<div class="flexbox" id="flex">
<div class="container" id="box1">
<a class="image-category" href="https://amh-solingen.de/scheren.html">
<img class="image-category" id="product3" src="/images/Schere.jpg">
</a>
<div class="image-description">
<p class="description">Haushalts- und Friseurscheren</p>
</div>
</div>
<div class="container" id="box2">
<a class="image-category" href="https://amh-solingen.de/haushaltsmesser.html">
<img class="image-category" id="product2" src="/images/Hero.png">
</a>
<div class="image-description">
<p class="description">Aktuelle Auswahl an Küchenmessern</p>
</div>
</div>
<div class="container" id="box3">
<a class="image-category" href="https://amh-solingen.de/klingen.html">
<img class="image-category" id="product3" src="/images/Klinge_7.jpg">
</a>
<div class="image-description">
<p class="description">Klingen für Haushaltsmesser</p>
</div>
</div>
</div>
I have created div with flex only one active in at a time. It seems working well in body with 1200px, but less than 1200px its start flickering due to inside hide/show (class content) on transition.
If I will not change content class display none from flex it is working well; but I need to switch display flex.
See codepen and snippet below:
$('.top div').click(function(){
$('.top div').removeClass('active')
$(this).addClass('active')
})
body {
background-color: #fff;
}
.top {
display: flex;
}
.top .item {
display: flex;
border: 1px solid black;
padding: 10px;
flex-grow: 1;
flex-basis: 0;
height: 180px;
transition: all .5s;
}
.top .item .flexo-box {
display: flex;
flex-basis: 0;
background: #f8f8f8;
box-sizing: border-box;
position: relative;
}
.top .item .flexo-box img {
width: 100%;
max-width: 180px;
}
.top .item .view-btn {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0;
z-index: 2;
background: #eeeeee;
}
.top > div:not(:last-child) {
margin-right: 20px;
}
.top .active {
background-color: white;
flex-grow: 4;
flex-basis: 0;
opacity: 1;
}
.content {
display: none;
box-sizing: border-box;
height: 100%;
}
.content .active-tab {
height: 50px;
}
.content .active-tab p, .content .archive-tab p {
font-size: 12px;
margin: 0;
}
.content .active-tab p.active, .content .archive-tab p.active {
background: blue;
}
.content .active-tab p.active + span, .content .archive-tab p.active + span {
background: blue;
}
.content .active-tab span, .content .archive-tab span {
font-size: 10px;
}
.item.active .flexo-box:hover .view-btn {
opacity: 1;
}
.item.active .content {
display: flex;
flex-grow: 2;
}
.item > div {
flex-grow: 1;
flex-basis: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="top">
<div class="item">
<div class='flexo-box'>
<img src="https://picsum.photos/200/300">
<span class="view-btn">
<a href="/jobs/12526/proof_documents/19776" class="btn btn-secondary proof__order__link ">
View File
</a>
</span>
</div>
<div class='content'>
<div class="active-tab">
<p>dfgsfgsfg<p>
<p class="active">012620_11254_LEN_78441.pdf</p>
<span>fsdfgfs0<span>
<div class="archive-tab">
<h3>Archived file</h3>
<p>012620_87896_LEN_11548.pdf</p>
<span> archived dfgfd4<span>
<p>012620_16975_LEN_98761.pdf<p>
<span>archived sdfgsfg</span>
</div>
</div>
</div>
</div>
<div class="item">
<div class='flexo-box'>
<img src="https://picsum.photos/200/300" alt="" onerror="this.src = 'http://10.0.0.73:3000/assets/placeholder-6c8626f646674836d73093c5cd6377a4b8a05f672e0f14147692482e930d9bba.jpg'">
</div>
<div class='content'>
hello
</div>
</div>
<div class='item active'>
<div class='flexo-box'></div>
<div class='content'>
hello
</div>
</div>
<div class="item">
<div class='flexo-box'></div>
<div class='content'>
hello
</div>
</div>
<div class="item">
<div class='flexo-box'>
<img src="https://picsum.photos/200/300" alt="" onerror="this.src = 'http://10.0.0.73:3000/assets/placeholder-6c8626f646674836d73093c5cd6377a4b8a05f672e0f14147692482e930d9bba.jpg'">
</div>
<div class='content'>
<div class="active-tab">
<p>current file<p>
<p class="active">012620_11254_LEN_78441.pdf</p>
<span>wertrwet 190314 1250<span>
<div class="archive-tab">
<h3>Archived file</h3>
<p>012620_87896_LEN_11548.pdf</p>
<span> wert ertrwet4<span>
<p>012620_16975_LEN_98761.pdf<p>
<span> 190309 1ertret152</span>
</div>
</div>
</div>
</div>
</div>
</div>
The display property can't be animated - so remove display: none from content and add these:
.item>.content {
min-width: 0;
flex: 0;
overflow: hidden;
}
Now the content will be zero-width and the flexo-box will occupy all space. Note the use of min-width: 0 - this allows the flex item to shrink beyond its content (default min-width of a flex item is auto).
Now you can add min-width: 0 to the item too for a smoother animation - see demo below:
$('.top div').click(function() {
$('.top div').removeClass('active')
$(this).addClass('active')
})
body {
background-color: #fff;
}
.top {
display: flex;
}
.top .item {
display: flex;
border: 1px solid black;
padding: 10px;
flex-grow: 1;
flex-basis: 0;
height: 180px;
transition: all .5s;
min-width: 0; /* added */
}
.top .item .flexo-box {
display: flex;
flex-basis: 0;
background: #f8f8f8;
box-sizing: border-box;
position: relative;
}
.top .item .flexo-box img {
width: 100%;
max-width: 180px;
}
.top .item .view-btn {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0;
z-index: 2;
background: #eeeeee;
}
.top>div:not(:last-child) {
margin-right: 20px;
}
.top .active {
background-color: white;
flex-grow: 4;
flex-basis: 0;
opacity: 1;
}
.content {
/*display: none;*/
box-sizing: border-box;
height: 100%;
}
.content .active-tab {
height: 50px;
}
.content .active-tab p,
.content .archive-tab p {
font-size: 12px;
margin: 0;
}
.content .active-tab p.active,
.content .archive-tab p.active {
background: blue;
}
.content .active-tab p.active+span,
.content .archive-tab p.active+span {
background: blue;
}
.content .active-tab span,
.content .archive-tab span {
font-size: 10px;
}
.item.active .flexo-box:hover .view-btn {
opacity: 1;
}
.item.active .content {
display: flex;
flex-grow: 2;
}
.item>div {
flex-grow: 1;
flex-basis: 0;
}
.item>.content { /* added */
min-width: 0; /* allow it to go to zero */
flex: 0; /* reduce the width */
overflow: hidden; /* hide oveflow */
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="top">
<div class="item">
<div class='flexo-box'>
<img src="https://picsum.photos/200/300">
<span class="view-btn">
<a href="/jobs/12526/proof_documents/19776" class="btn btn-secondary proof__order__link ">
View File
</a>
</span>
</div>
<div class='content'>
<div class="active-tab">
<p>dfgsfgsfg</p>
<p class="active">012620_11254_LEN_78441.pdf</p>
<span>fsdfgfs0</span>
<div class="archive-tab">
<h3>Archived file</h3>
<p>012620_87896_LEN_11548.pdf</p>
<span> archived dfgfd4</span>
<p>012620_16975_LEN_98761.pdf</p>
<span>archived sdfgsfg</span>
</div>
</div>
</div>
</div>
<div class="item">
<div class='flexo-box'>
<img src="https://picsum.photos/200/300" alt="" onerror="this.src = 'http://10.0.0.73:3000/assets/placeholder-6c8626f646674836d73093c5cd6377a4b8a05f672e0f14147692482e930d9bba.jpg'">
</div>
<div class='content'>
hello
</div>
</div>
<div class='item active'>
<div class='flexo-box'></div>
<div class='content'>
hello
</div>
</div>
<div class="item">
<div class='flexo-box'></div>
<div class='content'>
hello
</div>
</div>
<div class="item">
<div class='flexo-box'>
<img src="https://picsum.photos/200/300" alt="" onerror="this.src = 'http://10.0.0.73:3000/assets/placeholder-6c8626f646674836d73093c5cd6377a4b8a05f672e0f14147692482e930d9bba.jpg'">
</div>
<div class='content'>
<div class="active-tab">
<p>current file</p>
<p class="active">012620_11254_LEN_78441.pdf</p>
<span>wertrwet 190314 1250</span>
<div class="archive-tab">
<h3>Archived file</h3>
<p>012620_87896_LEN_11548.pdf</p>
<span> wert ertrwet4</span>
<p>012620_16975_LEN_98761.pdf</p>
<span> 190309 1ertret152</span>
</div>
</div>
</div>
</div>
</div>
I have 3 equal elements on the page (33.333% height each), when the user hovers over one of the elements I would like the height of that element to grow to 100%.
The first section works as I'd like it to, the 2nd section I would like it to grow from the top and bottom, pushing the elements above and below off of the screen - I can do this with absolute positioning, but then the elements above and below stay in the same place and the element grows over them (with the right z-index).
I've tried scaling the element, and using borders that increase/decrease, however I will be using background images and potentially videos so this won't work.
Here is a jsfiddle of what I have currently:
body {
height: 100%;
overflow: hidden;
}
.home-split {
height: 100vh;
}
.home-split .item {
height: 33.333%;
width: 100%;
transition: all 1s;
z-index: 999;
text-align: center;
}
.h-100 {
height: 100%;
}
.home-split .item:hover {
height: 100%;
transition: all 1s;
z-index: 9990;
top: 0 !important;
}
.home-split .item .title {
align-self: center;
}
.home-split .item a {
text-decoration: none;
color: #FFF;
display: table;
height: 100%;
width: 100%;
}
.home-split .item a h2 {
display: table-cell;
vertical-align: middle;
}
.home-split .item:nth-child(1) {
background-color: #000;
}
.home-split .item:nth-child(2) {
background-color: #d7d7d7;
}
.home-split .item:nth-child(3) {
background-color: #ebebeb;
}
<section class="home-split">
<div class="row no-gutters item">
<div class="col-12 text-center h-100">
<a href="#">
<h2>Item 1</h2>
</a>
</div>
</div>
<div class="row no-gutters item">
<div class="col-12 text-center h-100">
<a href="#">
<h2>Item 2</h2>
</a>
</div>
</div>
<div class="row no-gutters item">
<div class="col-12 h-100">
<a href="#">
<h2>Item 3</h2>
</a>
</div>
</div>
</section>
https://jsfiddle.net/d81mxuL5/
You need a less specific selector to hide all sections when the outer container is hovered:
.home-split:hover .item {
height: 0;
overflow: hidden;
}
friend I use JQuery to achive
$(".item").hover(function() {
$(this).siblings().css( "height", "1px");
$(this).css( "height", "98%");
}, function() {
$(this).siblings().css( "height", "33%");
$(this).css( "height", "33%");
});
body {
height: 100%;
overflow: hidden;
}
.home-split {
height: 100vh;
}
.home-split .item {
height: 33.333%;
width: 100%;
transition: all 1s;
z-index: 999;
text-align: center;
overflow: hidden
}
.h-100 {
height: 100%;
}
.home-split .item:hover {
height: 100%;
transition: all 1s;
z-index: 9990;
top: 0 !important;
}
.home-split .item .title {
align-self: center;
}
.home-split .item a {
text-decoration: none;
color: #FFF;
display: table;
height: 100%;
width: 100%;
}
.home-split .item a h2 {
display: table-cell;
vertical-align: middle;
}
.home-split .item:nth-child(1) {
background-color: #000;
}
.home-split .item:nth-child(2) {
background-color: #d7d7d7;
}
.home-split .item:nth-child(3) {
background-color: #ebebeb;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section class="home-split">
<div class="row no-gutters item">
<div class="col-12 text-center h-100">
<a href="#">
<h2>Item 1</h2>
</a>
</div>
</div>
<div class="row no-gutters item">
<div class="col-12 text-center h-100">
<a href="#">
<h2>Item 2</h2>
</a>
</div>
</div>
<div class="row no-gutters item">
<div class="col-12 h-100">
<a href="#">
<h2>Item 3</h2>
</a>
</div>
</div>
</section>
Demo: http://codepen.io/malte/pen/kDlbt
I am using an absolute positioned wrapper to center an image in a thumbnail frame. (Only) On mobile safari, the image won't be displayed. if you inspect the .image-pos container you'll see that the height is properly set to its parent's size. applying a fixed px height to it will make the image show up... Does anyone know how to fix that?
It's working on any Desktop browser...
HTML:
<div class="wrapper">
<div class="thumb-grid">
<div class="thumb">
<a href="#" class="image">
<div class="image-pos">
<img src="http://images.weserv.nl/?url=static.living.is/gallery/original/5184f3631034bcdf16bd4d37c341928e.jpg&il&w=600" />
</div>
</a>
<div class="details">
<h5>Image Title</h5>
</div>
</div>
<div class="thumb">
<a href="#" class="image">
<div class="image-pos">
<img src="http://images.weserv.nl/?url=static.living.is/gallery/original/5184f3631034bcdf16bd4d37c341928e.jpg&il&w=600" />
</div>
</a>
<div class="details">
<h5>Image Title</h5>
</div>
</div>
<div class="thumb">
<a href="#" class="image">
<div class="image-pos">
<img src="http://images.weserv.nl/?url=static.living.is/gallery/original/016e551de2f53d58e7f4acd68279e6a1.JPG&il&w=600" />
</div>
</a>
<div class="details">
<h5>Image Title</h5>
</div>
</div>
</div>
</div>
CSS:
.wrapper {
width: 600px;
margin: 30px auto 0
}
.thumb-grid {
text-align: justify;
}
.thumb-grid:after {
content: '';
display: inline-block;
width: 100%;
}
.thumb {
position: relative;
display: inline-block;
width: 31.5%;
height: 0;
padding-top: 29%;
margin-bottom: 6%;
}
.image {
height: 73%;
overflow: hidden;
position: absolute;
text-align: center;
top: 0;
width: 100%;
vertical-align: top;
display: block;
border: 1px solid #eee;
}
.image-pos {
height: 100%;
left: 50%;
margin-left: -300px;
position: absolute;
text-align: center;
width: 600px;
}
.image-pos img {
height: 100%;
max-height: 100%;
min-height: 100%;
max-width: none;
width: auto;
display: inline;
border: 0;
}
.details {
height: 27%;
position: absolute;
top: 73%;
}
.details h5 {
margin: 0;
padding-top: 5px;
}
Demo: http://codepen.io/malte/pen/kDlbt