I'm writing to ask if there is any simpler method to do exactly the same thing like in this code:
jsfiddle.net/t9euvoe9/5/
I'm trying to do friends list. I noticed that simple using of built borders isn't enough here. I found some way which in EVERY friend is divided by custom single line (botttom).
I want lines to dissapear when I'm hovering friend (BOTTOM line of PREVIOUS friend, and BOTTOM line of actually HOVERING friend). Also, these paddings are not working properly right now (when hovering).
edit:
I want to create friends list. Actually I have <div>
which contains all another <div class="friend">
. I want to separate every <div class="friend">
with a single line, which will be hidden after hoovering friend element
The way I'm actually doing this:
Position of <div class="friend">
element is set to relative. I'm creative custom border line using:before
and :after
pseudo-selectors.
When some <div class="friend">
is hovered, I'm hiding this border using display:none
. This hides bottom border. To hide top border I'm moving <div class="friend">
little bit higher by setting margin-top: 1%
and padding-top: 6%
to overcome this move.
Example:
.friend {
position: relative;
width: 100px;
padding-top: 5%;
padding-bottom: 5%;
}
.friend:hover {
margin-top: -1%;
padding-top: 6%;
height: calc(100% + 1px);
background-color: red;
}
.friend:hover:after {
display:none;
}
.friend img {
vertical-align: middle;
}
.friend:first-child:before {
content: '';
display: block;
width: 100%;
left: 10%;
height: 1px;
position: absolute;
background-color: #ccc;
top: 0;
}
.friend:after {
content: '';
display: block;
width: 100%;
left: 10%;
height: 1px;
position: absolute;
background-color: #ccc;
bottom: 0;
}
<div class="friend">
<img class="img-circle" src="http://www.zerohedge.com/sites/default/files/pictures/picture-197359.gif" alt="" width="40" height="40">
<span class="name">Ania</span>
</div>
<div class="friend">
<img class="img-circle" src="http://www.zerohedge.com/sites/default/files/pictures/picture-197359.gif" alt="" width="40" height="40">
<span class="name">Ania</span>
</div>