Is the middle part included?

What could be causing my "Section" to not align properly in the center?

I believed that this CSS should have resolved it:

section{
    width: 80%;
    margin-left: auto;
    margin-right: auto;
}

However, it seems like something went wrong. Can you identify the issue?

Here is the HTML code snippet:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
<title>LifeSymb.com</title>
    <link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<section>
    <article id="intro" class="scrollBlock">
            <h1>HOMES on the WEB</h1>

            <p>WHats going on, somekinda test text
            Likely to go and whats going to happen, hoihfedfh
            Fancy scrolling is going to Happen !!!</p>
    </article>
    <article id="slide2" class="scrollBlock">
            <h2>SLIDE 2</h2>

            <a href="http://google.com" id="photoSlide2"><img src="images/block2.png" alt="" /></a>
            <p>Text TUTYUYIUYOIUOIUiihjihiohiuhiuhuhuhuohoiuhoiyuoiuy</p>
            <p class="btn"><a href="http://google.com">Vist HERE!!!</a></p>
    </article>
    <article id="dog" class="scrollBlock">
            <h2>My dog has his own website</h2>

            <p>That's right! My dog Dog has his very own website full of cute doggy photos right from being a pup.<br/>
            <strong>Check out Jake's website at <a href="http://google.com">http://google.com</a></strong></p>
    </article>
</section>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="scripts/libs/jquery.scrollorama.js"></script>
<script src="scripts/scrollScript.js"></script>
</body>
</html>

And here is the related CSS styling:

body{
    font: 18px/30px Sans-serif;
    color: black;
    background:url('../images/bodyBG.png');
}

section{
    width: 80%;
    margin-left: auto;
    margin-right: auto;
}

.scrollBlock{
    width: 70%;
}

#intro{
    background: lightgreen url(../images/dragon.jpg) left no-repeat;
    /*background-size: cover;*/
}

    #intro h1{
        width: 677px; height: 122px;
        background: url(../images/btn_intro.png);
        text-indent: -9999px;
        position: relative;
        top: 145px;
        left: 0;
    }
    #intro p{
        position: relative;
        top: 200px;
        left: 350px;
        width: 508px;
        margin: 0 0 30px 0;
    }
    #intro p:nth-child(2){
        font-weight: bold;
    }


#slide2{
    background: lightpink url(../images/texture_purple.png);
}


#dog{
    background: black url(../images/dog.jpg)no-repeat;
    background-size: cover;
    padding-top: 400px;
}
    #dog h2{
        opacity: 0;
    }

Answer №1

Make sure to include the following in your CSS file:

section article {margin: 0 auto;}

This rule specifies that every article element inside a section should have zero vertical margin and automatic horizontal margin applied to it. (JSFiddle)

If your article elements are narrower than the section, it is necessary to center-align them as well.

Answer №2

Consider incorporating the CSS property "width:100%" into the <body> tag.

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

Tips for extracting the complete data file along with hyperlinks using AJAX

Upon selecting "Cities" on the left-hand menu, and choosing a city like Adelaide for example, a brief description of the city is displayed with dynamically embedded hyperlinks under the "Find Out More" text and below the "View Highlights" button at the bot ...

Having trouble locating the "forgot account" link below the password input field

While practicing website layout design, I attempted to emulate the Facebook landing page. Everything was going smoothly until I encountered an issue with the positioning of the “forgot account” link under the password input field. Strangely, it seems t ...

swap between style sheets glitching

My website features two stylesheets, one for day mode and one for night mode. There is an image on the site that triggers a function with an onclick event to switch between the two stylesheets. However, when new visitors click the button for the first ti ...

Prevent a div from scrolling once it reaches the end of its content, while allowing the other div to continue

I am trying to make the col-md-4 column stop scrolling once it reaches the end of the content, similar to the right sidebar on Facebook. I have attempted using jQuery to add a fixed position when it reaches the bottom, but it is not working as expected. Th ...

Retrieving the chosen option in Vue.js when the @change event occurs

I have a dropdown menu and I want to perform different actions depending on the selected option. I am using a separate vue.html and TypeScript file. Here is my code snippet: <select name="LeaveType" @change="onChange()" class="f ...

The CSS selector functions as expected when used in a web browser, however, it

While conducting test automation using Selenium, I typically rely on css selectors to find elements. However, I recently came across a peculiar issue. I observed that in certain cases, the css selector works perfectly when tested in the browser console. Fo ...

Conceal the overflow from absolutely positioned elements

I've gone through all the similar examples but still struggling to find the correct solution. My issue involves a basic Side Menu that toggles upon button click. Within the menu, there is a list of checkboxes positioned absolutely with the parent con ...

Why doesn't the date appear in the Textbox when the TextMode is set to "Date"?

Within my application, there are three textboxes named tbEditStartDate, tbEditStopDate, and tbEditRenewalDate. These textboxes are used to display the start date, stop date, and renewal date of applicants in a Gridview called gvApp. I have implemented a Ro ...

Utilizing Python to extract historical data from a designated website - extracting data from a table formatted within a form containing numerous rows and a distinct header. Automation is necessary for this

My current project involves data scraping from the website: Specifically, I am interested in extracting monthly weather data (30 dni a noci) from January 2012 to December 2013. My goal is to automate this process and save the obtained data in either a tex ...

How can I include inline CSS directly within a string instead of using an object?

Is there a way to write inline CSS in a string format instead of an object format? I attempted the following, but it did not work as expected: <div style={"color:red;font-weight:bold"}> Hello there </div> What is my reason for want ...

Having trouble finding a match between the local storage string and the URL string

Let me explain the concept I'm working on: Imagine you have a simple nested list: <ul> <li>chevy</li> <li>dodge</li> <li id="trucks">ford <ul> <li>ranger</li> <l ...

Ways to adjust color schemes in a grav template

Struggling with what should be a simple task. I have a website on Grav, utilizing a theme based on antimatter. The theme is mainly inherited and works perfectly fine. My goal is to make some color adjustments, specifically altering the background color of ...

What is the best way to ensure that the red overlay only covers the image without bleeding over to the right side as shown in the image?

As shown in the image, the red spill on the right side extends beyond the image Below is the HTML code I am using <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv=" ...

Using jQuery to toggle visibility of various elements without needing specific identifiers

I have coded a HTML and JS snippet for displaying and hiding a div element, which is currently functioning correctly. However, I want to be able to use multiple boxes on a single page and I need a way to determine which box-header was clicked. Is there a ...

The CSS module is disappearing before the Framer Motion exit animation finishes when the path changes

Source Code Repository: https://github.com/qcaodigital/cocktail_curations Live Site: I recently deployed my NextJS project to Netlify and everything seems to be working fine, except for one issue. Each page has an exit animation (currently set to change ...

Peeling back the layers of a particular element

This is my code snippet: <pre id='code'> <ol> <li class='L1'><span>hello</span></li> <li class='L2'><span>Hi</span></li> <li class='L3&apos ...

The content is not wrapped when transferred from App.js through props, although it is being wrapped in other scenarios

As I work on developing a basic invoice generator application, I encounter an issue with overflowing content in the "notes" section when passing data through props from the App.js file. Instead of wrapping the text, it overflows its container. import "./Ap ...

Surprising outcomes when hosting my website on its domain

During the development of my website, I uploaded it to Cpanel once everything was finished. It functioned perfectly fine at that time. However, after making some changes and uploading it again, the fonts and videos on the live domain appear larger than i ...

Unable to adjust the padding of a div while the Bootstrap 4 navbar is in a collapsed state on mobile devices

I am facing an issue with a fixed navbar at the top of my page. Below the navbar, I have the page content which includes a Bootstrap 4 image carousel. The problem arises on mobile devices where I need to add top-padding to the page-container (below the nav ...

Interactive World Map with Fluid Motion Animation built using HTML, CSS, and JavaScript

I am in need of an uncomplicated way to visually represent events taking place around the globe. This involves creating a 2D image of a world map, along with a method to show visual alerts when events occur at specific geographical coordinates [lat, lng]. ...