Demo link
Not sure why my text in the 2nd list isn't getting centered.
The HTML
<div id="the_target">
<ul>
<li>Stephen Marston</li>
<li>Account Exectutive</li>
<li>The Company</li>
</ul>
</div>
SASS:
section {
#the_requestor {
margin-top: 40px;
ul { margin-top: 10px; }
ul li {
text-align: center;
line-height: $px20;
}
li:first-child {
font-family: LatoBold;
font-size: $px30;
background: cyan;
}
}
#the_target {
position: relative;
margin-top: 40px;
ul { margin-top: 10px; }
ul li {
text-align: center;
line-height: $px20;
}
li:first-child{
font-family: LatoBold;
font-size: $px30;
background: cyan;
}
}
}
Any thoughts on what could be forcing Stephen Marston to not center?
To just center the text inside an element, use text-align: center; This text is centered.
This is because text-align:center only affects inline elements, and <aside> is not an inline element by default. It is a block-level element. To align it, we will have to use something other than text-align , or turn it into an inline element.
To center the text using float we can use margin-left or margin-right and make it 50% , like below.
Just give the list centered text (e.g. ul. nav { text-align: center; } ) and the list items inline-block (e.g. ul. nav li { display: inline-block; } ). If you want to do it with margin for whatever reason, look into width: fit-content; .
There is an element being floated in #mobile-action-area
that is interfering. You need to clear this float. There are a variety of ways to do it. Adding overflow: hidden
to #mobile-action-area
fixes it. You may also try:
#mobile-action-area:after {
display: table;
content: "";
clear: both;
}
You'll need to clear the float before #the_target
#the_target {
position: relative;
margin-top: 40px;
clear:both;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With