Using Bootstrap 3's hidden-xs class can help slim down the width of

I am currently testing out the Bootstrap 3 responsive grids and attempting to hide a column from a row when the screen size is small. However, I find that when the column disappears, the entire row seems to shrink in width.

Here's the code causing me some frustration:

<div class="container">
 <div class="row">
  <div class="col-xs-4 col-sm-2 col-md-1" align="center">
   Col1
  </div>
  <div class="col-xs-4 col-sm-2" align="center">
   Col2
  </div>
  <div class="col-xs-12 hidden-xs col-sm-6 col-md-5" align="center">
   Col3
  </div>
  <div class="col-xs-12 hidden-xs col-sm-12 hidden-sm col-md-3 " align="center">
   Col4
  </div>
  <div class="col-xs-4 col-sm-2 col-md-1" align="center">
   Col5
  </div>
 </div>
</div>

As the screen size decreases, Col4 followed by Col3 vanish but the row reduces in width with each disappearance (in contrast to a header row that remains constant). I have ensured that the total width of all columns adds up to 12 for each breakpoint, so I'm puzzled as to why this issue occurs. Initially, I suspected the culprit might be the col-xs-12, however deleting it prevents the column from disappearing at all or makes it merge with Col5!

There must be something that I am overlooking, but my quest for an answer has proven fruitless thus far – perhaps someone here can shed some light on this matter.

Answer №1

What happens if you only utilize visible-md for Col4? Would there be any need to use -lg at all in this case?

<div class="container">
    <div class="row">
        <div class="col-xs-4 col-sm-2 col-md-1" align="center">
            Col1
        </div>
        <div class="col-xs-4 col-sm-2" align="center">
            Col2
        </div>
        <div class="hidden-xs col-sm-6 col-md-5" align="center">
            Col3
        </div>
        <div class="visible-md col-md-3 " align="center">
            Col4
        </div>
        <div class="col-xs-4 col-sm-2 col-md-1" align="center">
            Col5
        </div>
    </div>
</div>

Answer №2

.container {
    padding-left: 10px;
}

add this snippet to your stylesheet

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

Choose the specific selector following the current selector

Consider this example of code: <script> $(document).ready(function () { $('span').each(function () { $(this).html('<div></div>') ; if ( $(this).attr('id') == 'W0' ...

Safari users may encounter issues with Web Audio playback in iOS 15 when the screen is locked for an extended period of time

After updating my iPod Touch to iOS 15 (15.0.1), an issue arose. Initially, the example below works perfectly, allowing me to play the sound multiple times without any problems. However, if I lock the screen on my iPod Touch and return a few minutes later ...

Angular back-end data filtering tutorial

I have a user input field where users can search or type in data, but I want to restrict them to only searching for predefined data that is available from the backend. I do not want users to be able to create new data by typing something that is not alread ...

Modifying CSS files in real-time

I've been attempting to dynamically change the CSS file, but I've run into an issue: Whenever I try to alter the style, it seems to work correctly while in "debug mode", showing that the changes are applied. However, once the JavaScript function ...

Is it possible to use CSS to change the order in which two elements are displayed?

Let's dive into a little experiment here. I am currently working on a page layout that is quite unique: <div id="container"> <div id="child1">...</div> <div is="child2">...</div> </div> My goal is to have ...

Using JSTL within JavaScript

Can JavaScript be used with JSTL? I am attempting to set <c:set var="abc" value="yes"/> and then later retrieve this value in HTML and execute some code. The issue I'm facing is that the c:set always executes even when the JavaScript condition ...

Theme.breakpoints.down not being acknowledged by MUI breakpoints

The Challenge: Implement a hamburger menu to replace the navMenu on tablet and smaller screens After successfully compiling in VS code terminal, encountering an error in the browser: Error Message: TypeError: Cannot read properties of undefined (reading ...

I am interested in implementing a logout feature using a button in PHP

<?php session_start(); ?> <form> <input type="button" id="logout" value="logout" name="logout"> </form> After initializing the session during login, I am seeking to terminate it using a button rather than via <a href="">l ...

Customize stepper background color in Angular Material based on specific conditions

I am working on a project using Angular Material and I want to dynamically change the color of the stepper based on different states. For example: state: OK (should be green) state: REFUSED (should be red) Here is what I have done so far: <mat-horizo ...

Transform all the code contained within the div tags into valid HTML format

I need to transform the content within a specific div from code to actual HTML, but I am unable to access the core files as I am working within a theme. Therefore, I must accomplish this task using javascript/jquery to convert the code within this particul ...

modifying the position of a container within the lower bounds of a surrounding container

I'm struggling to position the blue box at the bottom of this image, and I can't figure out why. Here is my CSS: .boxes { margin-left: 4%; margin-right: -4px; height: 345px; padding: 5px; font-size: ...

Ensure that the fixed header's width matches the size of the container div

The header element is contained within a div. I have positioned the header as fixed, leading to 2 issues: The width of the header extends beyond the width of the div container. It should align with the div. When the header is fixed, the other elements li ...

Resolving Problem of Jumping When 'invalid-feedback' Appeared in Bootstrap 4 Input

There is an input with an add-on and a customized focus that includes a '%' at the end of the field, which is working fine. However, there is a small issue where the error message causes the input to jump when clicked in or out. To see the issue ...

What is the best way to dynamically adjust the width of multiple divisions in Angular?

I am currently working on an angular project to create a sorting visualizer. My goal is to generate a visual representation of an array consisting of random numbers displayed as bars using divisions. Each bar's width will correspond to the value of th ...

Executing a PHP script

As I work on setting up a html form integrated with php for submitting user data to a database, I'm curious about the best tools to utilize in order to run and successfully test my program. Since it is a php file, what are the most efficient methods t ...

Tips for accessing the value stored within the parent element

As someone who is new to the world of javascript and typescript, I am currently working on an ionic application that involves fetching a list of values from a database. These values are then stored in an array, which is used to dynamically create ion-items ...

Keep the footer at the bottom of the screen without needing to define a 100vh in Material UI

In the process of developing my react app with MUI framework, I encountered various challenges in creating a sticky footer at the bottom of my screen. After exploring different solutions, one approach that I found most satisfactory is as follows: export de ...

Navigating currency in JavaScript

I'm considering whether this is the best approach for handling currency in JavaScript. The idea is to restrict the user to entering only numbers and a decimal point in the input field. This code is a combination of answers I found on this website and ...

I am encountering a continuous css ParserError while trying to compile my react project

I'm having trouble with the compilation of my React project. While everything runs smoothly with npm start, I encounter an error during compilation: npm run build <a href="/cdn-cgi/l/email-protection" class="__cf_ema ...

Injecting CSS styles into the head tag dynamically with jQuery from within the body of a

When it comes to adding CSS to the head of an HTML page from the body using JavaScript and jQuery, I have come across two methods. One involves using jQuery to directly append the CSS to the head, while the other method involves creating a style element an ...