What is preventing me from adjusting the background's position?

Recently, I've been working on a simple front page design but encountered an issue with moving my background. Despite trying different approaches like adjusting padding, the problem persists. As a beginner in coding, this has been quite a challenge, but I'm determined to figure it out! My goal is to center the container with the following background color: rgba(98, 97, 99, 0.25), ensuring equal spacing on both sides. Interestingly, the code appears correctly for me, except when viewed here, possibly due to Bootstrap usage.

body html {
    margin: 0;
    padding: 0;
}

.container {
    background-color: rgba(98, 97, 99, 0.25);
    padding-top: 4%;
}

.wrap{
    width: 1090px;
}
video {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    z-index: -100;
}

<!-- More CSS Snippets Here -->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>homepage</title>
    <link href="index.css" rel="stylesheet">
    <link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>

<!-- HTML Structure Here -->

</body>
</html>

Answer №1

Adjust the width of the container and center it using auto margins:

.container {
  background-color: rgba(98, 97, 99, 0.25);
  padding-top: 4%;
  width: 900px;
  margin-left: auto;
  margin-right: auto;

}

Answer №2

To achieve a container with float:left in css, you can also use clear both

body html {
    margin: 0;
    padding: 0;
}

.container {
    background-color: rgba(98, 97, 99, 0.25);
    padding-top: 4%;
    float:left;
}


.wrap{
    width: 1090px;

}
video {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    z-index: -100;
}

.wowImg {
    height: 255px;
    width: 255px;
    border-top: solid black 9px;
    border-bottom: solid black 9px;
    border-left: solid black 9px;
    float: left;
}

.venom {
    height: 255px;
    width: 255px;
    border-bottom: solid black 9px;
    border-left: solid black 9px;
    float: left;
}

.overwatch {
    height: 255px;
    width: 255px;
    border-top: solid black 9px;
    border-bottom: solid black 9px;
    border-right: solid black 9px;
    border-left: solid black 9px;
    float: left;
}

.sum41 {
    height: 255px;
    width: 255px;
    border-bottom: solid black 9px;
    border-right: solid black 9px;
    border-left: solid black 9px;
    float: left;
}

.middle {
    height: 510px;
    width: 550px;
    border-top: solid black 9px;
    border-bottom: solid black 9px;
    border-left: solid black 9px;
    float: left;
}

.whileSheSleeps {
    height: auto;
    width: 540px;
    border-bottom: solid black 9px;
    border-left: solid black 9px;
    border-right: solid black 9px;
    float: left;
}

.monster {
    height: 284px;
    width: 250px;
    border-bottom: solid black 9px;
    border-left: solid black 9px;
    border-right: solid black 9px;
    float: left;
}

.css_awesome {
    height: 284px;
    width: 285px;
    border-bottom: solid black 9px;
    border-left: solid black 9px;
    border-right: solid black 9px;
    float: left;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>homepage</title>
    <link href="index.css" rel="stylesheet">
    <link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">

    <div class="row col-md-12 wrap">
        <div class="row">
            <div class="col-md-12">
                <div class="wrap">


                    <div class="row col-md-3 upperLeft">
                        <div class="row">
                            <div class="col-md-12">
                                <img class="wowImg"img">
                                <img class="venom" src="img">
                            </div>
                        </div>
                    </div>

                    <div class="col-md-6  Middle">
                        <div class="row">
                            <div class="col-md-12">
                                <img class="middle" src "img">
                            </div>
                        </div>
                    </div>

                    <div class="row col-md-3 upperRight">
                        <div class="row">
                            <div class="col-md-12">
                                <img class="overwatch" src="img">
                                <img class="sum41" src="img">
                            </div>
                        </div>
                    </div>

                    <div class="row col-md-6 bottomLeft">
                        <div class="row">
                            <div class="col-md-12">
                                <img class="whileSheSleeps" src="img">
                            </div>
                        </div>
                    </div>

                    <div class="row col-md-3 bottomMid">
                        <div class="row">
                            <div class="col-md-12">
                                <img class="monster" src="img">
                            </div>
                        </div>
                    </div>
                    <div class="row col-md-3 bottomRight">
                        <div class="row">
                            <div class="col-md-12">
                                <img class="css_awesome" src="img">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
</html>

Answer №3

.box {
    background-color: rgba(100, 105, 110, 0.3);
    padding-top: 5%;
    width: 1024px;
    margin: 0 auto;
}

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

"Shopping just got easier with our new drag and drop feature! Simply drag items

I want to develop a Virtual Shopping Cart system. Items will be retrieved from a database. A virtual basket will be available. Users can drag items and drop them into the basket, similar to shopping in a mall. Once the user clicks the save button, the s ...

jQuery function fails to work on a list that has been dynamically generated

Can someone please assist me? I have encountered an issue where the dynamic list on the second page is not functioning properly. When I click any "li" element to trigger an alert for the respective "id" (which works fine for a hardcoded list), nothing happ ...

What is the best way to center my text vertically in each line?

I'm encountering an issue with aligning my text vertically in two lines within a <p> tag. I am trying to position the second line at the bottom of my <div>. I experimented with using vertical-align: bottom and text-bottom along with the to ...

There is a collision of boxes occurring within the CSS

Help Needed: Overlapping Boxes in Responsive Design I am facing a problem with my CSS where the boxes on my website are overlapping when I shrink the browser window. The issue occurs as I resize the window, causing the boxes to overlap more and more. I ...

Displaying HTML elements conditionally in React depending on boolean values

Developing a component that limits the display of text to the first 40 characters, but can show the full description when a Chevron click event is triggered. The goal is to have the content expand in a similar fashion as it currently does with the Accord ...

"Can I align a div in the center using inline-block with an

Despite my efforts, I still can't figure this out. My apologies for the duplication. I attempted to use text-align: center, margin: 0 auto;, and display: flex;, but none of them worked as expected in the end. I apologize for the messy formatting. ...

How is the script type "text/html" utilized in contemporary applications? Is this specific example regarded as effective usage?

Is it considered good practice in today's standards to utilize something like the following code snippet and use jQuery to swap out content based on a selector? <script type="text/html" id="this-content1"> <h1>This Header Info One</h1& ...

Button click not triggering Ajax functionality

I've been working on implementing a simple Ajax function in a JSP using JQueryUI. The goal is to pass two text fields from a form and use them to populate two separate divs. However, when I click the button, nothing seems to be happening. I even tried ...

Utilizing jQuery for Duplicating Elements

Can someone help me out with a jQuery question? I'm trying to figure out how to repeat an element multiple times using jQuery. Essentially, I want jQuery to create duplicates of an inline element indefinitely, similar to repeating a graphic for a back ...

"Enhance Your Website with Slider Swipe Effects using CSS3 and

After scouring the internet for various types of sliders, including swipe sliders, I am interested in creating a responsive swipe slider specifically for mobile phones. This would be a full page swipe slider where users can swipe left and right seamlessly. ...

"Creating a dynamic Map using the HERE Maps API and adjusting its size: A step-by-step guide

I am currently working on a Website project and I am interested in incorporating an interactive map from HERE Maps that spans the entire screen under my navigation bar. How can I achieve this? After initially using Google Maps, I switched to HERE Maps due ...

Replacing CSS conditional statements with jQuery

My CSS code is set to hide the #global-widget-base tag and display a tab #aside-expander when the browser width is less than 1200px. @media screen and (max-width: 1200px) { aside#global-widget-base { display: none !important; } #aside- ...

Can a draggable slider be implemented in jQuery to navigate between four different images?

I am working with 4 images and a slider setup like this: [image1.jpg]----[image2.jpg]----[image3.jpg]----[image4.jpg] -----------------------------[Slider]----------------------- My goal is to create an interactive feature where the slider can be clicked ...

Tips for loading various content types in Fancybox 3

I am utilizing Fancybox 3 for my gallery where I have disabled the opening/closing animation. Here is how I load my gallery: $(document).on('click', '[data-fancybox-var]', function(e) { e.preventDefault(); var links = $(' ...

How to position a centered div with a background image on a webpage

I am trying to achieve a centered layout for a div and its content on a webpage. The div includes a background image. Here is my approach using Flexbox: <head> <style> .flex_container { display: flex; flex-d ...

Updating the iframe source without reloading the main page

Within my ASP.NET website, I have a page that contains an iframe inside an Ajax Update Panel. I am able to change the src attribute of the iframe using JavaScript, but the issue is that when the src attribute is modified, it causes the parent page to refr ...

Create animations for ng-repeat elements without using ng-animate

Can the transition for changing the order of the model array in ng-repeat be animated using only CSS, without using ng-animate? ...

The footer fails to appear even after inspecting the element following the successful submission of my PHP email form

After implementing a PHP mail form on my website, I noticed that upon page load after filling out the email form, my footer does not appear and the tags are missing from the inspect element. The pages linked below show the issue: edit: Please note that th ...

Easy steps to dynamically add buttons to a div

I need help with a JavaScript problem. I have an array of text that generates buttons and I want to add these generated buttons to a specific div element instead of the body. <script> //let list = ["A","B","C"]; let list = JSON.p ...

Insert HTML code at the top of a WordPress page

Currently, I am in search of a solution for the following issue: I want to include a black bar at the top of every page using a plugin (similar to the WordPress admin bar that appears when you are logged in at wp-admin). Initially, I considered adding th ...