I have recently figured out a long time frustration of mine, so I figured I would jump on here and share it with the world. You’re welcome.
For years I have had a reoccurring annoyance, where I am given a list that must be centered on a page yet all individual items appear next to each other. In HTML speak, I want to place an “Unordered List” <ul> or an “Ordered List” <ol> on my page centered, but, I want the “List Items” <li> to be floating next to each other. I have “solved” this problem in the past by floating all the
left using CSS (float: left;). Then I set a width on the
or and give it an auto-assigned margin using CSS (width: 500px; margin: 0 auto;). This has been fine I guess. It just makes it a pain to perform mobile responsive CSS on the list. Because as the text shrinks you have to assign a new width to the
or at multiple sizes.
The Solution:
For some reason today as I was faced with this same problem it dawned on me that maybe I was thinking about this all wrong. Instead of trying to manipulate these list items to do my bidding within their blocks, I needed to remove the block styling and treat them as paragraph text. So simple.
All that needs to be done is to set your
or as position: relative; so it holds down the fort, display: block; so it takes up the space, and then give it a text-align: center;
Next, tell your <li> to have a width: auto; and to, and this is the magic, display: inline; Works every time, palm to forehead.
Sometimes, thinking outside the box is all it takes in CSS. #reallyproudofthatpun
Example:
List Item 1
List Item 2
List Item 3
The Code:
ul,
ol {
position: relative;
display: block;
text-align: center;
}
li {
width: auto;
display: inline;
}
Steck Insights Web Design seeks to provide professional, custom WordPress website solutions, quickly, efficiently and cost-effectively. You can count on us to follow web standards for safety, coding, SEO and speed.
Have you made fatal mistakes with your website? Fill in the form below to receive a comprehensive guide outlining the top 10 common website mistakes that you must avoid.
Branding InquiryFill out the form below if you're interested!
colorado, web design, design, advertising, brand, graphic design, denver, marketing, united states, web developer, content management system, search engine optimization, software engineering, email marketing, content marketing, wordpress, search engine, user experience, digital marketing, software, lead generation, experience, brand awareness, web development, website design, website development, colorado springs seo, development, digital marketing agency, custom web design, technology, target audience, domain name, mobile device, customer, usability, website, analytics, landing page, user experience design, internet, colorado springs web design, google analytics, conversion rate optimization, email address, marketing strategy, logo, management, hubspot, link building, reputation, online presence, business website, wordpress web design, web designers, wordpress website, web design agency, wordpress experts, affordable web design, web design services, web design seo, design services, web design company, web design web, small business marketing, web design colorado, keyword research, credibility, research, search engine marketing, javascript, responsive web design, user interface, customer service, competitor analysis, social media, html, attention, css, accessibility, organization, knowledge, content management, competitive advantage, navigation, strategy, google search, social media marketing
web development colorado springs, web design colorado springs, colorado springs web design, colorado springs website design, colorado springs web designers, website design colorado springs
Common Website Mistakes
When it comes to building a successful online presence, avoiding common website mistakes is crucial. Some of the most common mistakes include having a slow loading website, using outdated design elements, not optimizing for mobile devices, and neglecting search engine optimization (SEO). By addressing these issues and making necessary improvements, you can create a more user-friendly and effective website for your business.
Another common mistake is neglecting to regularly update and maintain your website. This can lead to security vulnerabilities, broken links, and outdated content that can turn away potential customers. By investing in a website maintenance plan, you can ensure that your website remains up-to-date, secure, and optimized for performance.