Ways to solve the padding issue in Bootstrap 5

I am encountering an issue with setting the padding in my fluid container. The top-down padding is set to 3%, but the left-right padding of 15% is not working as expected. After debugging using Chrome Developer Tools, I noticed that the left-right padding was crossed out. Can someone please help me figure out what is wrong here?

<div class="container-fluid">
  <div class="navbar navbar-expand-lg navbar-dark">
    <a class="navbar-brand" href="">Tindog</a>    
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarTogglerDemo01">
        <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>
  </div>





  <!-- Title -->

  <div class="row">
    <div class="col-lg-6 col-md-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 col-md-6">
      <img src="images/iphone6.png" alt="iphone-mockup">
    </div>
  </div>
</div>

CSS FILE

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

Answer №1

Ensure that the "

Answer №2

When using Bootstrap containers, they come with preset horizontal padding. If you want to restrict the width, you can use the following code snippet:

<div class="container-fluid" style="max-width: calc( 100% - (15% * 2) )">...</div>

Answer №3

In my experience, bootstrap comes with preset margin and padding dimensions, making it tricky to set custom dimensions that actually work effectively.

The container-fluid class in bootstrap is set and cannot be easily overridden. To customize the padding, you will need to add another class in addition to it.

Alternatively, refer to the documentation for guidance on how to customize: https://getbootstrap.com/docs/5.2/layout/containers/#how-they-work

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

Animate the leftward disappearance of a div to make it vanish

My goal is to create a user interface where users can navigate through different divs. Here is the HTML code: <article id="realize" class="realizeBox"> <div class="shown"> <div class="heading"> <h2>Realisati ...

Tips for resolving the Firefox display problem with input[type="file"] using CSS

After researching articles, it became clear to me that input[type="file"] displays differently across various web browsers. I am in need of a simple solution using only CSS to address this issue as I only require adjusting the width of the element. The w ...

triangle shape filled with a gradient that transitions between two colors

I have two triangles displayed at the bottom of my page - one on the left and one on the right. The right triangle is currently transparent but I want to add a gradient effect to it. For the triangle-bottom-right, I'd like the gradient to go from rgb ...

Adjust the content of a table cell using jQuery

<td>09 Mars 2020</td> Using the string above, I have created a div. Here are the Jquery variables I am working with: date1 = 09 Mars 2020 date2 = 18 Mars 2020 My goal is to combine the content from another date with the existing date to ach ...

Difficulty integrating Bootstrap with JavaScript file in Visual Studio Code

I am attempting to incorporate a dynamic progress bar by utilizing Bootstrap's progressbar and creating a custom JavaScript file. The goal is to continuously adjust the width of the progress bar at regular intervals to give the appearance of a moving ...

Is Your Website Sluggish because of an Excessive Amount of JavaScript on Page

After finally resolving some of the Javascript issues I was facing, I have streamlined my code to utilize just one library now, which is a huge improvement from how chaotic it was before. However, I have noticed a slight delay in the page load time, and I ...

Filling an HTML template with an $http response in VueJS

After learning about VueJs, I decided to embark on a small project - a nutrition app where food recommendations are made based on specific nutrients. Below is the JavaScript code snippet: recommendFood: function() { this.recs = {}; ...

Is it possible for Spring Boot to initiate an action that will dynamically update an image in an HTML document using JavaScript or another method?

I am currently facing a challenge in updating an image on a website built with HTML, while utilizing Spring Boot as the backend technology. As of now, I am using JavaScript to update the image at regular intervals, but the timing does not align with when t ...

Move the Form to the Top of the Window and Highlight the First Input Field

There's a link in the header that says "Let's chat": <div class="letstalk"> <a href="javascript:scrollForm();"> Let's chat <img src="/wp-content/uploads/link-icon.png"> </a> </div> ...

Concealing a div element if the value is null

Here's my code: if ($image1 !=='') { //Insert div here } However, I'm encountering parse errors when I try to place the div within the curly brackets. Is there a specific syntax or format that I am missing...? ...

Animating elements on a webpage can be achieved by using both

Is there a way to create an animation that moves objects based on button clicks? For example, when the "Monday" button is pressed, the object with the correct color will move down. If any other button like "Tuesday" is clicked, the previous object will mov ...

Could there be a scenario where the body onload function runs but there is still some unexec

I am feeling confused by a relatively straightforward question. When it comes to the <body> tag being positioned before content, I am wondering about when the body onload function actually runs - is it at the opening tag or the closing tag? Additio ...

How can I combine HTML and CSS in a single request using the sendFile method in Express?

const app = require('express')(); app.get('/', function(req, res) { res.sendFile(__dirname + "/" + "index.html"); }); <link rel="stylesheet" href="style.css"> I utilized the Node.js code above to send an HTML file. In order to ...

When the second column is hidden, I aim to have the first column expand to fill the entire width

My HTML code currently has a setup where the first div takes up all the width when the second div is made invisible. While this method works, I am curious if there is a more elegant way to achieve this in Bootstrap 5.1: <!DOCTYPE html> <html> ...

centering an angular material card on the webpage

Currently, I have developed a Registration script that enables users to Sign Up on my website. However, the issue I am facing is that the angular material card, which houses the sign up interface, is not centered. Despite trying various methods such as & ...

Set the search input to occupy the full width of the container by utilizing Bootstrap's

I'm having trouble adjusting the width of my search input to 100% on screen resize (using @media (max-width: 1200px)). The issue: https://i.sstatic.net/EMr6W.jpg Here's how it should look (I can achieve this with a specific pixel width, but not ...

Elements shifting positions based on the size of the window

I am facing an issue with positioning the register form on my website. I want it to be fixed at the bottom-right corner of the window, without reaching the top. Although I managed to achieve this, the problem arises when the screen resolution changes. For ...

What is the best way to include a div element with a dynamic animation on a webpage?

I'm attempting to create a laser beam that can shoot enemies on the screen, much like in classic games such as Space Invaders or Galaga. However, I am encountering difficulties getting the laser to move when I click the button. Below is the code I hav ...

Trouble loading antd's less styles

In my NextJs project, I have the following file structure: -pages -_app.tsx -app -styles -antdstyles.less Within _app.tsx, I am attempting to import @styles/andstyles.less, which simply imports antd styles like this: @import '~antd/di ...

Click on the radio button to delete all selected entries in the option dropdown

After spending the entire day trying to find a solution, I am still struggling with a simple task - how do I clear all selections from a group of select option drop downs at once without removing them? I want the selections to revert back to their default ...