Arranging content for mobile and desktop using Bootstrap grid system

Having an issue as follows: I am trying to create three columns that are displayed side by side on desktop in fullscreen mode. On mobile devices, I want these same three columns to be displayed in three rows beneath, also in fullscreen.

Here is a sketch of the layout for desktop: https://i.sstatic.net/uIIYa.png

And here is a sketch of the layout for mobile: https://i.sstatic.net/WDUZ1.png

Below is the code that I have so far. It is currently functioning properly on desktop but not on mobile devices.

#eshop{
    background-color: red;
}

#truhlarna{
    background-color: blue;
}

#bahnak{
    background-color: yellow;
}

.col-md-4{
    overflow: auto;
    padding-bottom: 100%;
    margin-bottom: -100%;
}

.col-xs-12{
    
}
<!DOCTYPE html>
<html>
    <head>
        <title>Bakes Wood</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
        <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
       
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
         <link href="css/style.css" rel="stylesheet" type="text/css"/>
        
        
    </head>
    <body>
        <div class="container-fluid kontejner">
            <div class="row">
                <div id="eshop" class="col-xs-12 col-sm-4 col-md-4">A</div>
                <div id="truhlarna" class="col-xs-12  col-sm-4 col-md-4">B</div>
                <div id="bahnak" class="col-xs-12  col-sm-4 col-md-4">C</div>
            </div>
        </div>
    </body>
</html>

Any assistance would be greatly appreciated.

Thank you!

Answer №1

To optimize mobile device display, utilize a media query and `vh` unit.

.col-md-4{
     overflow: auto;
     height:100vh;
}    

@media (max-width:768px) {
        .col-md-4{
            height:33.33vh;
        }
    }

Check out the demo here: http://www.codeply.com/go/AUD3fMsx6Q

Answer №2

After grasping the concept of using the vh dimension unit, I made some adjustments to my code over on CODEPEN

CSS:

.col-md-4 {
  height: 100vh;
}

@media (max-width: 768px) {
  .col-md-4 {
    height: 33.33vh;
  }
}

Originally, I interpreted the request as wanting each section to be full screen on mobile devices. However, upon closer inspection, it seems that three rows beneath should be displayed fullscreen. With this in mind, I made the necessary changes. Thanks to zimsystem for the guidance :)

Answer №3

Your solution was a perfect combination in resolving the issue.

@media (max-width:768px) {
    .col-md-4{
        overflow: auto;
        height:33.33vh;
    }
}

@media (min-width:769px) {
    .col-md-4{
        overflow: auto;
        height:100vh;
    }
}

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

Adjusting the placement of elements according to the size of the screen?

I'm facing a very specific issue with my web page design and I need some ideas on how to solve it. The current structure of the page looks like this: <div class="row"> <div id="home-img" class="col-6"> ******An Image Goes He ...

Guide on interacting with a button using Chrome driver and Selenium in Python

Hello everyone (please forgive any mistakes in my English), I am trying to automate the process of downloading a file from this webpage by clicking on a button. Below is the code snippet I'm currently using: download_dir = 'C:/Users/Francesco.B ...

Ways to configure an Express.js server file with the router path set as the root directory

I have a directory structure set up like this root private js css index.html app.js privateRouter.js ... Within my index.html, I am referencing the js and css files using relative paths: <link rel="stylesheet" href="css/index.css" ...

Looking for a regular expression to require either a dollar sign ($) or a percentage symbol (%) but not

At the moment, I currently have this input field set up on an HTML page within my Angular 9 application: <input type="text" formControlName="amountToWithholdInput" onkeyup="this.value = this.value.replace(/[^0-9.%$]/, &ap ...

The <a> tag behaving uniquely when encountering the <div> tag

Apologies for the vague title, I struggled to find the right words to express my issue. I have been working on creating a web page using an HTML document. Initially, I used <div> tags to structure the page and everything seemed to be in order. Howev ...

Tips on positioning the image to the left of your content instead of above it

Currently, I am following a tutorial on Flask and attempting to include the profile picture in each article displayed on the website. Here is the code snippet used to display an article: <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a ...

The Typewriter Effect does not appear alongside the heading

For my portfolio website, I am using React to create a unique typewriter effect showcasing some of my hobbies. Currently, the code is set up like this: "I like to" [hobbies] However, I want it to display like this: "I like to" [h ...

Fixing issues in PHP File Editor

At our web development company, we have created an online file editor and file manager script for our website users to easily manage their files and customize their templates. This script is written in PHP and allows users to edit html, text, php, js, jque ...

Ways to locate an element using document.getElementById when no id is assigned to the element

I am currently working with an input element that looks like this: <input type="text" name="emailId" size="30" value="" /> A third-party JavaScript script needs to add a class to this element for tracking purposes. The script, which is loaded from ...

Utilizing Partial Views and Ajax for Dynamic Modal Content in Django with Bootstrap

Seeking advice on two questions. I'm not looking to copy and paste exact code, but rather for guidance towards helpful resources on the internet where I can learn (what's the point of copy and paste if you don't learn?) 1) I remember partia ...

Using Angular 5 custom validations in combination with Bootstrap 4 validation pseudo-classes (:valid, :invalid)

Bootstrap 4 validation styles are based on the classes form-control:valid and form-control:invalid. Angular provides the option to apply any custom class when a field is in error. If I adhere to the specifications outlined here: https://getbootstrap.com/d ...

A layout featuring a grid design that includes spacing and gutters between items, however, there is no spacing between the items

I am looking to create a grid layout where each child element represents an individual grid square. However, I am facing an issue with spacing between the children and the parent container, which is not desired. How can I eliminate this unwanted space? U ...

Visual Studio is refusing to highlight my code properly, intellisense is failing to provide suggestions, and essential functions like go to definition are not functioning as expected

Due to a non-disclosure agreement, I am unable to share any code. However, I am experiencing an issue with Visual Studio not highlighting my code or allowing me to utilize its built-in tools. While I can rebuild the project, I cannot edit or access any fil ...

Cross-platform mobile browsers typically have scrollbars in their scrollable divs

I have successfully implemented scrollable div's on a page designed for tablets running Android 3.2+, BlackBerry Playbook, and iOS5+ (except iPad 1). However, I would like to add scrollbars to improve the user experience. For iOS5, I can use the suppo ...

Unable to add data to an Array once subscribed to BehaviorSubject

Hello everyone, this is my first time asking a question here. I hope it's clear enough for you to understand :) Let's dive straight into the issue at hand. I have a query regarding a behaviorSubject variable in TypeScript that is not allowing me ...

using jquery to select elements based on their data attribute values

I have a question about using jQuery to select an object with a specific data value. For instance: $('[data-infos-parent_id=0]').html('it ok'); <div class="question" data-infos='{"parent_id":0,"my_id":0, "title":""}'> ...

Troubleshooting Problem with Bootstrap 4 Navigation Drop-Down Menu

I am working on developing some navigation forms for my university projects. I encountered an issue where I selected the Book item, and the navigation was working fine. However, when I selected Child items and then clicked on the Organization item, the nav ...

overlaying a div on top of an HTML5 canvas

I'm currently attempting to position a div element on top of a canvas on the center of my webpage in order to create a start screen for a game. This start screen will display options like "Play game" and "Settings". Despite conducting thorough researc ...

Error Message: "Duplicate variable declaration detected"

This piece of code is causing me some major headaches. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <a href="#" data-source="ryedai">Ryedai</a> <a href=&q ...

Sprockets could not locate the file for jquery.atwho

I have been attempting to integrate the jquery-atwho-rails into my application, a Rails gem designed for at.js. I have followed all the steps provided, executed bundle install, included the necessary code in both application.js and application.css, stopped ...