Reputation: 27
I am trying to align images horizontally but they are all lying on top of each other.
I am pretty new to this so struggling to figure this out!
Any help would be appreciated!
<div class="social">
<ul>
<div class="facebook">
<li><a href="#"></a></li>
</div>
<div class="twitter">
<li><a href="#"></a></li>
</div>
<div class="youtube">
<li><a href="#"></a></li>
</div>
<div class="vimeo">
<li><a href="#"></a></li>
</div>
</ul>
</div>
Here is the css
.social {
width: 50%;
margin: 0;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-top: 30px;
display: inline-block;
position: relative;
}
.social ul {
list-style: none;
margin: 0;
padding: 0;
}
.social ul li {
margin: 0;
padding: 0;
display: inline;
}
.facebook a:link {
background-image: url(../img/facebook.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
position: absolute;
}
.facebook a:hover {
background-position: bottom;
}
.twitter a:link {
background-image: url(../img/twitter.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
position: absolute;
}
.twitter a:hover {
background-position: bottom;
}
.youtube a:link {
background-image: url(../img/youtube.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
}
.youtube a:hover {
background-position: bottom;
}
.vimeo a:link {
background-image: url(../img/vimeo.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
}
.vimeo a:hover {
background-position: bottom;
}
Here is the code in JSFiddle http://jsfiddle.net/hdnrwrmj/
Upvotes: 0
Views: 182
Reputation: 234
Here is the updated HTML & CSS
JSFIDDLE
I have removed div in ul. its not actually as per standards.
Upvotes: 0
Reputation: 4580
I would suggest to remove the div
s and add the class names to the li
s and also remove the absolute position. Fiddle
EDIT: Also use inline-block
display for li
s
HTML
<div class="social">
<ul>
<li class="facebook"><a href="#"></a></li>
<li class="twitter"><a href="#"></a></li>
<li class="youtube"><a href="#"></a></li>
<li class="vimeo"><a href="#"></a></li>
</ul>
</div>
CSS
.social {
width: 50%;
margin: 0;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-top: 30px;
display: inline-block;
position: relative;
}
.social ul {
list-style: none;
margin: 0;
padding: 0;
}
.social ul li {
margin: 0;
padding: 0;
display: inline-block;
}
.facebook a:link {
background-image: url(http://www.cruisedeals.com/images_shared/top-deal-star-35px.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
}
.facebook a:hover {
background-position: bottom;
}
.twitter a:link {
background-image: url(http://upload.wikimedia.org/wikipedia/ca/thumb/a/a0/Logo_upc.png/35px-Logo_upc.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
}
.twitter a:hover {
background-position: bottom;
}
.youtube a:link {
background-image: url(http://data.cyclowiki.org/images/thumb/d/dc/ClericiMariani.png/35px-ClericiMariani.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
}
.youtube a:hover {
background-position: bottom;
}
.vimeo a:link {
background-image: url(http://mkhx.joyme.com/images/mkhx/thumb/8/88/%E5%9C%B0%E7%8B%B1.png/35px-%E5%9C%B0%E7%8B%B1.png);
width: 35px;
height: 35px;
background-position: left;
display: block;
border: none;
outline: none;
}
.vimeo a:hover {
background-position: bottom;
}
Upvotes: 1