The background colors are not extending to the full width of the screen

I am facing an issue in my CSS code while trying to create a footer. The background color is not filling the width of the screen, and I had encountered the same problem earlier.

Here is how it looks: (https://i.sstatic.net/5VxYU.png)

HTML Code:

*{
    margin: 0;
    padding: 0%;
    box-sizing: border-box;
}

@font-face {
    font-family: "Sodo Sans";
    src: url("/fonts/sodo-sans-regular.woff2") format("woff2"),
         url("/fonts/sodo-sans-regular.woff") format("woff");
    font-weight: normal;
    font-style: normal;


}

body{
    font-family: "Sodo Sans", sans-serif;
}

.navbar{
    display: flex;
    align-items: center;
    padding: 20px;
}

nav{
    flex: 1;
    text-align: right;
}

nav ul{
    display: inline-block;
    list-style-type: none;
}

nav ul li{
    display: inline-block;
    margin-right: 20px;
}

a{
    text-decoration: none;
    color: #555;
}

p{
    color: #555;
}

.container{
    max-width: 1300px;
    margin: auto;
    padding-left: 25px;
    padding-right: 25px;

}

.row{
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-around;
}

.col-2{
    flex-basis: 50%;
    min-width: 300px;
}

.col-2 img{
    max-width: 100%;
    padding: 50px 0;
    width: 450px;
}
.col-2 h1{
    font-size: 50px;
    line-height: 60px;
    margin: 25px 0;
}

.btn{
    display: inline-block;
    background: #069972;
    color: #fff;
    padding: 8px 30px;
    margin: 30px 0;
    border-radius: 30px;
    transition: 0.5s;
}

.btn:hover{
    background: inherit
}


.header{
    background: radial-gradient(#fff,#ffd6d6);
}

.header .row{
    margin-top: 70px;
}

.catagories{
    margin: 70px 0;
}

.col-3{
    flex-basis: 30%;
    min-width: 250px;
    margin-bottom: 30px;
}

.col-3 img{
    width: 100%;
}

.small-container{
    max-width: 1080px;
    margin: auto;
    padding-left: 25px;
    padding-right: 25px;
}

.col-4{
    flex-basis: 25%;
    padding: 10px;
    min-width: 200px;
    margin-bottom: 50px;
    position: relative;
    transition: 0.3s ease-in-out;
}
.col-4 img{
    width: 100%;
}
.title{
    text-align: center;
    margin: 0 auto 80px;
    position: relative;
    line-height: 60px;
    color: #555;
}

.title::after{
    content: '';
    background: #073eb6;
    width: 80px;
    height: 5px;
    border-radius: 5px;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

h4{
    color: #555;
    font-weight: normal;
}
.col-4 p{
    font-size: 14px;
}

.col-4:hover{
    top: 5px;
}
/*------------- offer -------------*/
.offer{
    background: radial-gradient(#fff, #ffd6d6);
    margin-top: 80px;
    padding: 30px 0;
}

.col-2 .offer-img{
    padding: 50px;
}
small{
    color: #555;
}

/*------------- testimonial -------------*/
.testimonial{
    padding-top: 100px;
}

.testimonial .col-3{
    text-align: center;
    padding: 40px 20px;
    box-shadow: 0 0 20px 0px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: 0.5s;
}

.testimonial .col-3 img{
    width: 50px;
    margin-top: 20px;
    border-radius: 50%;
}

.testimonial .col-3:hover{
    transform: translateY(-10px);
}

.fa.fa-quote-left{
    font-size: 34px;
    color: orange;
}

.col-3 p{
    font-size: 15px;
    margin: 12px 0;
    color: #777;
}

.testimonial .col-3 h3{
    font-weight: 600;
    color: #000;
    font-size: 19px;
}

/*------------- brands -------------*/

.brands{
    margin: 100px auto;
}

.col-5{
    width: 160px;
}

.col-5 img{
    width: 100%;
    cursor: pointer;
    filter: grayscale(100%);
    transition: 0.25s;
}

.col-5 img:hover{
    filter: grayscale(0);
}


/*------------- footer -------------*/
.footer{
    background: #000;
    color: #8a8a8a;
    font-size: 14px;
    padding: 60px 0 20px;
}

I am new to HTML/CSS coding and would greatly appreciate any help. If there is an answer or solution available elsewhere, please guide me as I may not be able to describe the problem accurately.

Answer №1

Your .footer has black background and padding defined for the .small-container element, causing the footer not to take up the full width due to the left and right padding in that container.

To resolve this issue, I attempted to remove the padding from the .small-container by commenting out the padding-left and padding-right properties:

.small-container{
    max-width: 1080px;
    margin: auto;
    /*
    padding-left: 25px;
    padding-right: 25px;
    */
}

However, this resulted in a lack of padding overall on the page.

Therefore, I reverted the CSS rule above and instead moved the footer element outside of the container, ensuring that it does not inherit the padding while the rest of the document does.

*Note: There was also missing closing div tag at the end of your body section. This could cause issues with the structure of your HTML document.

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

Utilizing preg_match in PHP to validate a textarea for alphanumeric characters, numeric values, and spaces

I've almost got everything working, but I'm stuck on how to utilize preg_match. I checked the manual here http://php.net/manual/en/function.preg-match.php, but it doesn't clearly explain the syntax for creating my own validation. For example ...

Steps for embedding a dynamic 3D model onto a website with THREE.js

Seeking guidance on integrating animated 3D models onto a webpage using THREE.js. Currently, I have successfully loaded a static 3D model named 'aaa.gltf' with auto rotation and orbit control functionality. However, when trying to load another an ...

What causes the disruption of vertical alignment among inline-block elements when using overflow:hidden?

Take a look at these two JSFiddles: http://jsfiddle.net/am28dsbz http://jsfiddle.net/am28dsbz/1/ Why is it that the first one shows my text aligned correctly, while the second one displays the first link lower than the second? Stack Overflow requires m ...

Automatically resizing a multi-part CSS background based on content dimensions

My current CSS project has hit a snag that I can't seem to solve: There is a box on the left side of the site that contains three images - a top image, an optional and stretched middle image, and a bottom image. I want this left box to automatically ...

The color attribute in a Div container remains the same even when hovering over it

Hello everyone, I am new to stack overflow so please bear with me. I am currently working on this small webpage for my IT course and I have encountered a significant issue. .float1 { float:right; background-color:#A3635C; margin-top: 150px; ...

Trouble with HTML Contact Page Email Delivery

Hello there, I recently set up a contact page for my html website but unfortunately, it's not sending the messages to my email as expected! You can see what I mean in this screenshot -> https://i.stack.imgur.com/2xPXw.png I'm a bit puzzled b ...

Is it possible to generate distance between 2 elements without utilizing padding or margin?

In my React Native project, I'm currently working with 2 inline buttons - the search and add buttons: https://i.stack.imgur.com/tKZrf.png I'm looking to add some spacing between these buttons without impacting their alignment with the left and ...

Neglecting to review the CSS - embracing ejs layouts in Express

I am encountering an issue with the express ejs layouts where only the mainPage is able to read the CSS, while the other pages are unable to do so (even though the HTML reads it). Additionally, if I want to use another layout such as "layout2.ejs", what s ...

Creating a new dynamic page can be achieved by clicking on a dynamically generated link. Would you like to learn how to do that?

Recently, I developed a custom API using Node.js to retrieve information about blogs from Medium.com. The API currently provides: The author/main picture of the article Title A link to the article on medium.com (redundant) The entire article text in the ...

Tips for adding a class to the output of a jQuery ajax request?

I've been searching for a solution to this issue without any luck. Below is the code I have: jQuery("#categories_parent_id").change(function() { id = jQuery("#categories_parent_id").val(); jQuery.ajax({ type: ...

Identifying the Nearest Div Id to the Clicked Element

When a link is clicked, I am trying to locate the nearest div element that has an id. In this specific scenario, the target divs would be either #Inputs or #Stages. For example, if Page1 through 4 is clicked, I want to store the id #Inputs in a variable. ...

How can I implement a jQuery slide down effect for a specific individual instance?

Whenever I click on the "Share your thoughts" button, the comments block slides down for every section instead of just the particular section I clicked on. Is there a way to make it so that only a single block slides down when the button is clicked, regard ...

Is there a way to dynamically toggle the visibility of a floating textarea between on and off?

I have my own blog website: Essentially, what I am aiming for is When a user clicks on the search button, a floating semi-transparent textarea window should appear inside the designated rectangle area (as shown in the image, that red orange rectangle). ...

Tips for updating WordPress without changes appearing live right away

I want to quickly and easily make CSS changes to a WordPress website without doing it live. Is there a way to make these changes locally and then upload them? What is your recommendation? Some people have mentioned that making changes locally can be diffi ...

Adjusting the text of a button when hovering over it will also trigger a resizing of the

Currently, I am facing an issue where the bootstrap button's size changes when hovered over. My intention is to have the bootstrap button remain a fixed size while only the text inside it changes using javascript for mouseover and mouseout events. How ...

Showing content in a way that spaces out below the text

Could someone assist me with a CSS problem I'm having? I understand CSS, but debugging is not my strong suit. When I use display: inline-block for both my Academic Information and Personal Information, I'm getting extra white space below (above " ...

Styling Lists: How to Create a Second Line Indent with Counters

There seems to be an issue with the second line indent when using a custom counter. When attempting to use 'list-style-type: decimal', the numbering does not display as desired, for example: ol { counter-reset: ci-counter; list-style- ...

Personalize the md-tab component in Angular 2

I'm encountering an issue with styling the md-tab component in Angular 2. While I understand that Angular 2 Materials is currently under development, I am wondering if there is a way to customize it, such as removing the bottom-radius. Below is an exa ...

Page flickers when jQuery is used to scroll to an element

One issue I have encountered is with a link that, when clicked, should scroll down to a specific element on the page. However, every time I test this feature, there seems to be an inconsistency where the page may momentarily flash before scrolling as inte ...

Footer not sticking to bottom using bootstrap version 5.2.2

I am currently working on a project using Laravel Inertia Vue and bootstrap 5.2.2 as part of my dependencies. After loading the css to the tag, I attempted to create a sticky footer. However, I found that the footer is not sticking to the bottom as expect ...