Utilizing padding within Bootstrap with a fluid container

I am facing an issue with the Bootstrap container fluid. Adding padding using CSS is not working as expected, and I noticed that it only works when we use the !important declaration. Do you have any insights on why this might be happening? Below is the code snippet:

.container-fluid {
    padding: 3% 15% !important;
}

Here is the HTML code snippet:

<body>
        <section id="title">
            <div class="container-fluid">
                <!-- Nav Bar -->
                <nav class="navbar navbar-expand-lg navbar-dark">
                    <a class="navbar-brand" href="">Tindog</a>
                    <button
                        class="navbar-toggler"
                        type="button"
                        data-toggle="collapse"
                        data-target="#navbarSupportedContent"
                        aria-controls="navbarSupportedContent"
                        aria-expanded="false"
                        aria-label="Toggle navigation"
                    >
                        <span class="navbar-toggler-icon"></span>
                    </button>
                    <div class="collapse navbar-collapse" id="navbarSupportedContent">
                        <ul class="navbar-nav ms-auto">
                            <li class="nav-item">
                                <a class="nav-link" href="">Contact</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="">Pricing</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link" href="">Download</a>
                            </li>
                        </ul>
                    </div>
                </nav>

                <!-- Title -->

                <div class="row">
                    <div class="col-lg-6">
                        <h1>Meet new and interesting dogs nearby.</h1>

                        <button type="button">Download</button>
                        <button type="button">Download</button>
                    </div>
                    <div class="col-lg-6">
                        <img src="images/iphone6.png" alt="iphone-mockup" />
                    </div>
                </div>
            </div>
        </section>

And here is the related CSS code:

#title {
    background-color: #ff4c78;
}

.container-fluid {
    padding: 3% 15%;
}

h1 {
    font-family: "Montserrat", sans-serif;
    font-size: 3rem;
    line-height: 1.5rem;
}

Answer №1

There's a common issue that occurs when you place your custom CSS styles before linking the Bootstrap style sheet in your HTML document. When the browser renders the page, it follows a top-down approach. If there are conflicting style definitions (such as using the same class name like .container-fluid), the styles from the last linked style sheet will take precedence and override your custom styles.

To fix this: Make sure to link your custom style sheet after all other style sheets like Bootstrap, Font Awesome, etc.

If you share the code within the <head> tag, I can confirm if this is the issue.

P.S. It looks like you're working on the TinDog project following Angela Yu's course. Feel free to check out my code on GitHub for reference.

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

What is the method to access an HTML page div using JavaScript?

I'm currently developing a login page using phonegap with android. Upon successful login validation, I need the user to be directed to the welcome section if they are authorized. Here is my javascript code from the file called myjavascrpt.js: var ...

Why are the elements not aligned in a single row?

Can anyone explain why these two elements are not displaying on the same row when using Bootstrap 4? <div class="container"> <div class="row"> <div class="col-lg-2"> <a class="logo"><img class="logo__img" src= ...

Is it possible to trigger a script tag based on certain conditions using a JavaScript function?

I'm currently working with Angular and have a requirement to trigger a third party script from a function located within another script tag. Here's an example scenario: Within the index.html file let displayOnHomepage = () => { if (win ...

Assigning a Sass variable to an HSL value does not function properly when attempting to utilize it with HSLA

My Sass variable is mapped to an hsl value, but when I try to use it with hsla to add transparency, it doesn't work. This is what I'm trying to do: $white:hsl(100, 100%, 100%); .thing{ color:hsla($white,.9); } When using gulp-sass to build my ...

Mistakes are triggered when a non-submit button is clicked in Angular Reactive Forms

Working with angular 7 and a material design toolkit, I have encountered an issue with a form that has multiple validations and two buttons. One button is for opening the file picker (labeled as 'upload image'), while the other one is for submitt ...

The mobile devices are not showing my HTML website

I have implemented the following CSS link code on my website: <link rel="stylesheet" href="index_files/front.css" media="all" type="text/css" > Additionally, I have included the following code <meta name="HandheldFriendly" content="True"> & ...

Issues with div and hyperlinks/forms

I am currently working on creating a left sidebar in my HTML code, but I am still new to this. In the div for the sidebar, I have three buttons. However, Weebly keeps notifying me of an issue with the <a> tag, and the second button's link appear ...

Adding a horizontal scrollbar to an iframe: A step-by-step guide

My issue involves embedding this iframe element <iframe src="https://opendsa-server.cs.vt.edu/OpenDSA/Books/Everything/html/Write.html#recurWriteStepsCON" scrolling="no" id='frameid1' width=100% height=330px></iframe& ...

Ways to transform a CSS image to scale proportionally

Is there a way to zoom in on an image using the background-url property without affecting other elements? Here's what I have so far: .fakeImg:hover img{ transform: scale(1.1); } However, I need the image to grow only inside the specified div. C ...

obtaining extra space in the final portion of a table cell

I've been attempting to place the image and text next to each other, but I couldn't figure out how to make the image adjust its size (height & width) to fit into the table cell. Additionally, there seems to be extra space and the background color ...

What steps can be taken to prevent double division within a loop?

Appreciate your assistance. This is the structure of my code: var CatItems = ""; for(var x=0; x < data.PRODUCTS.length; x++) { if (x % 3 === 0) CatItems += '<li class="jcarousel-item jcarousel-item-horizontal jcarousel-item-'+[x]+' ...

Scrape embedded content within an IFrame on a webpage with Java

Currently, I am interested in crawling the dynamic content within an IFramed webpage; Unfortunately, none of the crawlers I have tested so far (Aperture, Crawl4j) seem to support this feature. The result I typically get is: <iframe id="template_cont ...

Utilizing Touch Inputs to Resize Panels in GWT

Recently, I encountered a challenge with the size of my Panel while loading numerous widgets inside it. To address this issue, I opted to utilize a Resizable Panel in GWT, which initially proved to be effective. However, my current dilemma lies in adaptin ...

New HTML5 feature enables users to upload images onto canvas, enabling them to drag, rotate, and even

I'm a beginner in Html5 and I'm having trouble with uploading an image to the canvas. When I provide the direct source of the image, it works fine. I referred to this link for help javascript: upload image file and draw it into a canvas. Let me s ...

Is it possible to merge CSS transitions and animations?

Hi there, I'm encountering an issue when trying to combine CSS transitions and animations. It seems that when I add a transition, it cancels out the animation that is working. Does anyone have any insights on how to successfully merge them together? ...

Centering elements in CSS with a full-width approach

My goal is to centralize all the elements on a webpage so that when the browser size is modified, the content shifts accordingly. Currently, I am using the following CSS code: margin: 0px auto; width: 670px; However, I am facing a challenge in trying to ...

The Gridview fails to render on the screen

I have a gridview on my webpage that is configured with template fields in each column, allowing me to input information and save it to my database. The gridview does not directly link data, but rather provides the functionality to add multiple rows at o ...

Arranging various JavaScript arrays

I've been working on a script using the Haversine formula, but I'm running into an issue where it always directs me to the first location in the array, no matter how many times I switch them around. Any suggestions? var locations = new Array( ...

Does clicking on a link open an iframe and automatically scroll to the top of the page?

Is there a way to make a link open a new page in an iframe and automatically redirect the webpage to the top of the screen? I'm hoping to achieve this using only HTML/CSS code. ...

Ways to eliminate the lower boundary of Input text

Currently, I am working on a project using Angular2 with Materialize. I have customized the style for the text input, but I am facing an issue where I can't remove the bottom line when the user selects the input field. You can view the red line in t ...