What could be causing the bootstrap columns to automatically shift onto separate lines?

Check out my code snippet:

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

.row {
  width: 100%;
  height: 80%;
  margin: 0px;
  padding: 0px;
}

body {
  background: #EFEFEF;
}

.container-fluid {
  width: 100%;
  height: 80%;
  margin: 0;
  padding: 0px;
  border: 3px solid;
  border-color: #848484
}

.navbar-brand {
  position: absolute;
  margin-top: auto;
  margin-left: 20px
}

#post-container {
  margin-left: auto;
  margin-right: auto;
  border: 3px solid;
  border-color: #FF0000
}
<div class="container-fluid">
  <nav class="navbar"> <img class="navbar-brand" src="images/Ventr_Logo.svg" alt="Ventr Logo" width="100"> </nav>
  <div class="row">
    <div class="col-lg-4 col-md-3 col-sm-2" style="background: #4E4E4E"></div>
    <div class="col-lg-4 col-md-6 col-sm-8" id="post-container">
    </div>
    <div class="col-lg-4 col-md-3 col-sm-2" style="background: #4E4E4E"></div>
  </div>

The main column with light gray background and red border is the focal point. When viewed on a tablet-sized screen, the layout maintains a 6:3 ratio as desired. Check it out this image.

The issue arises when viewed on a mobile phone: Look at this image. Instead of 3 columns in line with an 8:2 ratio, they break into separate columns.

How can this problem be resolved? Additionally, the column sizes should adjust dynamically based on screen size.

Answer №1

When working with bootstrap, keep in mind that the "col-sm" class kicks in at 768 pixels. If you want to specifically target smaller screens, you can opt for "col-xs" (576 pixels or more) or simply "col" for very small screens.

To make the change, just swap out "col-sm-2" with "col-2" :

  <div class="row" >
    <div class="col-lg-4 col-md-3 col-2" style="background: #4E4E4E"></div>
    <div class="col-lg-4 col-md-6 col-8" id="post-container">
    </div>
   <div class="col-lg-4 col-md-3 col-2" style="background: #4E4E4E"></div>
</div>

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

A comprehensive guide on how to find keywords within an array and then proceed to make all text within the parent div tag stand

I am currently looking for a webpage that displays a list of products based on keywords from an array. Once it detects any word in the array, it highlights it with a red background - everything is working smoothly so far. However, I now wish for the script ...

I found myself pondering over possible solutions to rectify this parse error

I need help resolving an issue with parsing. Here is the link to the error image: https://i.stack.imgur.com/jKQat.jpg. Additionally, my HTML code connecting to the CSS site can be found here: https://i.stack.imgur.com/ST31r.jpg. The website I linked in t ...

Attempting to extract tabular information from a script function housed within a webpage

I'm attempting to extract data from a table on the following website: When using BeautifulSoup to 'find' the 'table', I encountered a NoneType error since the table appears to be generated by a script function that fetches 90 rand ...

Dimensions of CSS Buttons

On my screen, I have 3 buttons with varying sizes determined by their padding. As the text wraps within each button, they adjust in height accordingly. However, the issue arises when the buttons end up being different heights. Instead of setting a specific ...

Loading images in advance using JavaScript

I have been searching through multiple forums and cannot seem to figure out the issue. The problem I am encountering is related to a website where there are three images with a hover effect. When the page first loads, there is a delay in loading the backgr ...

Utilizing Angular and the Kendo UI framework to customize the dimensions of a Kendo window

Is there a way to dynamically set the height and width of the kendo window based on the content of the kendo grid? Below is the code snippet for my kendo-window: <div kendo-window="Operation.OperCustWind" k-width="800" k-height="700" ...

What is the best way to eliminate HTML unicode content from the final item in a continuously changing list?

li:after{ content:"\00b6"; } <ol> <li>banana</li> <li>orange</li> <li class="last-class">apple</li> </ol> I am currently working on a dynamic list where the number of <li> tags varies over t ...

Guide on validating an Australian phone number with the HTML pattern

When it comes to PHP, I have found it quite simple to validate Australian phone numbers from input using PHP Regex. Here is the regex pattern I am currently using: /^\({0,1}((0|\+61)(2|4|3|7|8)){0,1}\){0,1}(\ |-){0,1}[0-9]{2}(\ | ...

Error in the code that I am unable to locate in JavaScript, HTML, and CSS

I need help creating a navbar that displays the active site using HTML and JS code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content=& ...

Checking forms for standard regulations with jQuery

Within my project, I have implemented multiple forms, where each form shares common fields like email, but also contains its own unique fields such as uniqueFieldA for Form A and uniqueFieldB for Form B. The challenge at hand is to develop a set of valida ...

What is the best way to access HTML attributes within a JavaScript function when working with a dynamic element?

When a user interacts with an HTML element on my website, I aim to display the attributes of that specific element in a new browser tab. An example of such an HTML element is: <a id="d0e110" onclick="GetWordFile(this.id)" attr1="attr1_value" attr2="at ...

What methods can I use to guarantee that a cloned HTML element retains a specific property during Unit Testing?

During my HTML cloning process, I am using the following code snippet: var clone = document.getElementById('tempID').cloneNode(true); After creating the clone, I need to modify its ID by assigning a new unique identifier with clone['id&apo ...

Update the chosen option of the <select> element that was generated through PHP if there is a parameter value present in the URL

I'm currently working on a code snippet like this: <select name="id" id="id"> <OPTION VALUE="null">Select<OPTION> <? foreach ($genres as $row){ ?> <OPTION VALUE="<? echo $row->id; ?>"><? echo ...

Having issues with my JavaScript timer - seeking assistance in troubleshooting the problem

Trying to set a timer for my little game, but facing some difficulties. The timer causes the balance to randomly increase from 0 to 13000 + some extra amount. <script> var coins = 0; var speed = 1; </script> <center> <h4> ...

Retrieving PHP information in an ionic 3 user interface

We are experiencing a problem with displaying data in Ionic 3, as the data is being sourced from PHP REST. Here is my Angular code for retrieving the data: this.auth.displayinformation(this.customer_info.cid).subscribe(takecusinfo => { if(takecusi ...

View the text notes information stored in a database, make changes to them, and then update and save the modified data using NodeJs

Currently developing a website that allows users to register, login, write text notes in a text area, save them in a database, and view those saved notes on a separate page. Additionally, users should be able to click on a note from the list and have it ...

Connecting a hero image in CSS for Flask application: a step-by-step guide

Adding a hero image to my Flask app page has been challenging. Here is the directory structure of my Flask project: -static |--css_files |--my.css |--images |--img.jpg -templates |--layout.html In order to incorporate a hero image, I have includ ...

Addressing the spacing and alignment issues within the progress bar

I need some help with my Angular app. I am currently working on creating a progress bar, but I am facing some issues with the alignment of the bars. Here is the code snippet that I have used: CSS: .progressbar { position: relative; height: 56px; mar ...

CSS for Page Header with Scroll-Over Content

Having trouble creating a "collapsing header" design where the page content scrolls over the banner image. I've tried adjusting z-index and positioning properties in CSS, but can't achieve the desired effect. Any help or guidance would be greatly ...

Exploring HTML list with padding to determine optimal wrapping configurations

Having an issue with a section of links. The blocks for the links are lining up next to each other when the viewport is wide, but I want one block labeled MOBOT to drop down onto a new line in a small responsive space. The goal is for the MOBOT square to ...