I want to get these two elements to align perfectly vertical side by side using a position value of relative. I'm having trouble as to understanding why these two elements don't want to align.
Can someone explain what I'm doing wrong? and if possible find a solution?
https://jsfiddle.net/kerberonix/qcq68gfg/
HTML
<html>
<body>
<footer>
<div class="test">
<p>Footer Text</p>
</div>
<ul class="social-links">
<li>Link 1</li>
<li>Link 2</li>
</ul>
</footer>
</body>
CSS
footer {
position: absolute;
bottom: 0;
width: 100%;
height: 70px;
padding: 0 20px;
background-color: #262626;
}
.test {
position: relative;
display: inline-block;
top: 50%;
width: 50%;
transform: translateY(-50%);
}
footer p {
font-size: 100%;
color: #888;
}
.social-links {
position: relative;
display: inline-block;
top: 50%;
width: 50%;
transform: translateY(-50%);
}
.social-links li {
display: inline-block;
margin-right: 35px;
text-decoration: none;
}
.social-links li:last-child {
margin: 0;
}
I would remove all of the positioning on the text and social elements, and use display: flex; align-items: center;
on the parent.
footer {
position: absolute;
bottom: 0;
height: 70px;
padding: 0 20px;
background-color: #262626;
display: flex;
align-items: center;
box-sizing: border-box;
left: 0; right: 0;
}
.test {
position: relative;
}
footer p {
font-size: 100%;
color: #888;
}
/*--------------------------------------------------------------------------------------------
SOCIAL LINKS
--------------------------------------------------------------------------------------------*/
.social-links {
position: relative;
color: white;
text-align: right;
padding: 0;
}
.test, .social-links {
flex: 1 0 0;
}
.social-links li {
display: inline-block;
margin-left: 35px;
text-decoration: none;
}
.social-links li:last-child {
margin: 0;
}
<html>
<body>
<footer>
<div class="test">
<p>Footer Text</p>
</div>
<ul class="social-links">
<li>Link 1</li>
<li>Link 2</li>
</ul>
</footer>
</body>
</html>