Reputation: 23
I'm trying to make that one div in a navbar gets a top-padding when I hover it. My problem is that all my divs makes the same effect (they all go down), and I just want one of them to make this (the one I'm hovering), and I want the others to stay in the same place, with the same height, without any changes.
The current situation is this one: http://jsfiddle.net/3S8ZB/1/
This is my current CSS:
div {
height: 2em;
width: 6em;
border-radius: 5px;
background-color: orange;
display:inline-block;
}
div:hover{
padding-top:2em;
}
What do you suggest?
Upvotes: 2
Views: 35
Reputation: 250
Not sure if understood becuse it looks like you are very close to that. Padding on the hovered item and keeping the siblings vertically aligned to the top.
div {
height: 2em;
width: 6em;
border-radius: 5px;
background-color: orange;
display:inline-block;
vertical-align: top;
transition: padding .5s ease-in;
}
div:hover{
**padding-top:2em;**
}
Upvotes: 2
Reputation: 11496
inline-block
elements are vertically bottom alligned
by default. Add vertical-align: top;
css
div {
height: 2em;
width: 6em;
border-radius: 5px;
background-color: orange;
display:inline-block;
vertical-align: top; /* add this */
}
div:hover {
padding-top:2em;
}
Upvotes: 2