Div rejects being aligned in the center

To view the issue live, please visit this link:

The "content" class (which is a container div) on my website has an uneven margin where the left side is larger than the right. Despite numerous attempts to troubleshoot in my CSS code, I am unable to identify the root cause of this discrepancy. It used to work perfectly fine not too long ago, but now it's misaligned.

Interestingly, when I remove the id Navbar or id Header divs, the Content div aligns back to the left as expected. This only adds to my confusion and frustration with the situation.

Here is the specific CSS code causing the issue:

.content{
    display:inline-block;
    margin:0 auto;
    width: 68%;
    overflow:hidden;
    text-align: center;
    padding: 10px;
    background-color: #FFFFFF;
    font-size: 12px;
    border-radius: 10px 10px 10px 10px;
}

For reference, here is a snippet of the HTML code:

<body>
    <div class="header">
        <p>Tucson Bagley</p>
    </div>

    <div id="socialmedia">
            <a href="https://twitter.com/BagelHero"><img src="images/Twitter_logo_blue.png"/></a>
            <a href="http://www.linkedin.com/in/tucsonbagley"><img src="images/linkedin.png"/></a>
            <a href="https://www.facebook.com/tucson.bagley"><img src="images/facebook.png"/></a>
    </div>

    <div id="header">
            <small><a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0c4e6d6b696044697e634c6b6560226f6361">[email protected]</a></small>
    </div>
    <div id="navbar">
        <ul>
            <li><a href="index.html"><span>Gallery</span></a></li>
            <li><a href="about.html"><span>Resume/CV</span></a></li>
            <li><span>Contact me</span></li>
        </ul>
    </div>

    <div class="content">
        <div class="thumbleft"><h2>This is some content.</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin non varius metus. Pellentesque eu nunc tortor. Aliquam id lectus orci. Sed id consectetur eros. Curabitur semper nisl nibh, rhoncus lacinia nibh volutpat at. Pellentesque sollicitudin vitae ipsum ut dictum. Proin ac risus ac nisi interdum hendrerit. Pellentesque sodales mauris ac eleifend vehicula. Nulla convallis aliquet urna varius auctor. Donec eget ipsum ut mauris consequat auctor eget sit amet odio. Nullam sed lorem erat. Praesent consequat porttitor magna, sit amet feugiat odio tincidunt ut. Fusce congue eros vel quam condimentum, vel consectetur quam imperdiet. </p>
        </div>

    </br>

    <div id="copyright">
        <p>Copyright 2012-2014 | Tucson Bagley</p>
    </div>

</body>

I would appreciate any assistance in resolving this issue. Thank you in advance!

Answer №1

Insert a

<div style="clear:both"></div>
above the .content div, change the styling of .content from display:inline-block to display:block, and you're all set!

Answer №2

Revamp the style of your .content to achieve this new look

.content{
    position: fixed;
    left:10px;
    right:10px;
    display:inline-block;
    margin:15px auto;
    width: 75%;
    overflow:hidden;
    text-align: center;
    padding: 12px;
    background-color: #EFEFEF;
    font-size: 14px;
    border-radius: 15px;
}

The key lies in the left:10px paired with right:10px and margin:15px auto which will only be effective in fixed mode.

Edit - revised css based on feedback.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Styling elements with CSS and using it to toggle the visibility of divs based on radio

When the radio button #my102 is selected, the div #navi102 should be visible and all other #navi??? divs should be hidden. Similarly, if the radio button #my7 is selected, the div #navi7 should be visible and others hidden. What would be the best approach ...

Recognizing unattended mouse interactions

The question goes beyond what the title suggests, but essentially comes down to this issue. Let me provide some context: In my application, I am utilizing Chromium's rendering/content/javascript engine for user interfaces. Beneath the user interface ...

The Twitter Bootstrap 3 navbar on the right side, positioned outside the collapsible navbar

When using Twitter bootstrap 2.3.2, I could implement the following code snippet: http://jsfiddle.net/aQwUZ/3/ <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> ...

Tips for updating a specific section of a Django webpage using AJAX

Currently, I am in the process of launching a website using Django. One crucial application on this site is the 'forum' which facilitates discussions among users. The discussion forum can be accessed through the URL 'XXX.com/forum/roomY&apo ...

CSS - With the abundance of positioning methods available, determining the right approach can be quite a puzzle

As I delved into web development, my fascination with positioning grew. In the beginning, my novice websites were structured like this: <body> <h1> Welcome to my website. </h1> <br> <br> <br> <br> <br> ...

Angular's md-button disrupts alignment

Adding an md-button seems to be causing some issues with the span element in my code. The number "5" is not displaying properly and it goes down. How can I fix this problem? Here is the HTML: <button md-button class="special-orders">special offers ...

The mix-blend-mode has no impact on any element

Despite my efforts to find solutions online, my CSS is refusing to cooperate even after trying various methods that worked for others. Here, you can view a JSFiddle where I have replicated the issue: I am aiming for the side navigation to be visible on th ...

Creating a circular clipping effect on a CSS3D element using Three.js

Utilizing the incredible Three.js CSS3D renderer has allowed me to achieve exceptional performance across various devices, including phones, tablets, and desktops. I successfully integrated an overview Google map as a CSS3D object that dynamically rotates ...

trouble executing a straightforward xpath search

I'm having trouble with this piece of code: Notice: Trying to get property of non-object in test.php on line 13 Despite what seems to be a correct xpath query and the presence of tags in the provided URL, the code is not returning the expected resul ...

Refresh your HTML page automatically while keeping the scroll position and functioning with anchors

I am currently facing an issue with a web service that generates HTML and I need it to automatically refresh in the browser every 10 seconds. Initially, I used the <meta http-equiv="refresh" content="10"> method which worked successfully, maintaining ...

Google Chrome applying its unique style compositions

I recently started transitioning a website from HTML to Wordpress, and encountered an unexpected challenge with Google Chrome applying unfamiliar styles. Specifically, the issue lies with the positioning of the background image bg.gif. While Internet Explo ...

Unable to Send Messages through HTML Email Form

I have recently obtained a Bootstrap website template and I am facing an issue with the functionality of the form that is supposed to send messages to my email. Despite filling in all the required fields, the message confirms submission but no actual email ...

What is the best way to trigger a download of an external image (AWS signed URL) when a button is clicked?

Currently, I am facing a challenge attempting to download an image from an s3 Presigned URL upon clicking a button in Nextjs (client-side). To provide some context: On the backend, I'm utilizing Golang and on the front end, it's the Nextjs Reac ...

Is it possible to trigger a JavaScript function when scrolling down a specific div?

I have a scenario where I have three different div elements. Whenever I scroll down on any of these divs, I want to trigger a JavaScript function that makes an AJAX call. The data for these divs (with ids 'doc', 'user', and 'lawfir ...

Arrange a div element within another div by utilizing the fixed positioning property, while also accounting for any potential "white space

Can someone help me figure this out: I currently have this much progress: http://jsbin.com/apikiw/3/edit#preview The issue I'm facing is that I am unable to insert it between the <p /> tags due to its dynamic nature... any solutions or suggest ...

Bootstrap container with added page border

Allow me to explain the issue to the best of my ability: I have a design that needs to be implemented using bootstrap. I prefer to use only CSS and avoid JS/jquery. The content is contained within a bootstrap container that has two columns. The left gre ...

How can we incorporate interactive icons into the navigation bars on our Weebly site?

Recently, while using Weebly to design a website, I stumbled upon a webpage () that explains how to add icons to the navigation bar. Below is the code provided: /* External Fonts */ @font-face { font-family: 'dashicons'; src: url('fonts/ ...

Are there any specific CSS classes or directives in Angular for disabled controls in Reactive forms?

I am dynamically disabling controls in a reactive form based on specific conditions. I also wish to apply custom styling to those disabled controls. Does Angular automatically add a CSS class or directive to disabled controls? I have not come across any. ...

Javascript code for creating a dropdown menu with clickable options

I have implemented a JavaScript function that creates three clickable drop-down menu buttons on my webpage. When I click on one button, the script works correctly and displays the corresponding menu. However, when I click on another button, the new menu is ...

Exploring potential methods for generating a PDF invoice in PHP and CodeIgniter by utilizing HTML elements

Greetings everyone, I have encountered a common question on stackoverflow. I am currently working on an HTML invoice template similar to the one showcased in this demo page. My goal is to create a PDF file of the invoice when users click on a specific butt ...