/    Sign up×
Community /Pin to ProfileBookmark

CSS – Centering inline list li within bootstrap 3 column

I’m trying to horizontally center inline list items within a bootstrap 3 col class but it keeps moving it to the left side of the column.

note – I should add that I left the “justify-content: center;” style in there cause that was the last thing I tried, but I do not necessarily want them justified (using up all the space of the column), but rather just centered within that div and extra space on the sides.

here it is on my test server http://gojibop.devlocation.site

`<div class=”hidden-xs hidden-sm col-md-6 “>
<ul class=”nav navbar-nav sticky-only text-center” style=”display: flex; justify-content: center;”>
<li><a href=”#RESTAURANT”>RESTAURANT</a></li>
<li><a href=”#MENU”>MENU</a></li>
<li><a href=”#LOCATION”>LOCATION</a></li>
<li><a href=”#INFO”>INFO</a></li>
</ul>
</div><!– close col –>`

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumMar 02.2020 — justify-content comes into effect only when there is empty space in the flex container. You have to make the ul fill the wrapping container, then the items inside will be centered:
element.style {
display: flex;
justify-content: center;
width: 100%;
}
×

Success!

Help @aaron4osu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...