I want to have a short text to the left, and to the right, some social icons.
The logic is the following: I have a paragraph element <p>
with some text, which is left centered (float:left
), and after this text, inside this paragraph, I have an horizontal list of social icons, created with <span>
, which is aligned to the right (float:right
).
Still, it does not work, because icons appear below the text:
This is the fiddle (although icons do not work, because they are imported).
HTML:
<p class="post-meta"> April 7, 2017
<span class="share-icons">
<ul class ="social-icons" style="list-style: none">
<li class="zocial-twitter"></li>
<li class="zocial-facebook"></li>
<li class="zocial-googleplus"></li>
<li class="zocial-reddit"></li>
</ul>
</span>
</p>
CSS:
@import url(http://weloveiconfonts.com/api/?family=zocial);
/* zocial */
[class*="zocial-"]:before {
font-family: 'zocial', sans-serif;
}
.post-title {
text-align: left;
font-weight: 700;
}
.post-meta {
margin-top: 0;
color: grey;
font-weight: 700;
overflow: hidden;
}
.share-icons {
float: right;
}
.social-icons li {
display:inline;
padding: 5px;
}
3
Answers
You need to cancel the padding-start
(the default for Chrome, at least, is 40px)
As Gurtej Singh advise.
Change your markup. Ul must be outside the paragraph. I added parent element so we can use flex for vertical alignment.
Here is a solution based on your code ,I moved the
<span>
and clean a classhttps://jsfiddle.net/r1ngjh6k/2/