Tips for resizing and reordering bootstrap columns based on different screen dimensions

I need to rearrange my bootstrap columns.

HTML

<div class="row equal">
   <div class="panel  col-lg-7  col-md-7  col-sm-6 col-xs-push-12 "  id="PanelFirst">
     Insert content here...
   </div>
   <div class="panel col-lg-5  col-md-5 col-sm-6  col-xs-pull-12 " id="PanelSecond">
     Insert Content here....
   </div>   

I have experimented with col-xs-pull and col-xs-push classes. I also tried pull-left and pull-right classes. Additionally, I attempted to use media queries for smaller screens.

@media only screen and (max-width:480px)
{
    #PanelFirst {
        float: right;
    }

    #PanelSecond {
        float: left;
    }
}

Using col-xs-pull-12 and col-xs-push-12 classes affects larger screens as well. I aim to shift the entire PanelSecond above and PanelFirst below specifically for xs size screens.

https://i.sstatic.net/WjDE2.png The layout is satisfactory for large screens, but on small screens, the login area should be at the top. However, it currently looks like this.

https://i.sstatic.net/mNx2W.png

Answer №1

EXAMPLE:

http://example.com/sample-page

Remember to prioritize designing for mobile devices first in situations like these. It will make the solution much simpler.

<div class="row equal">
     <div class="panel col-xs-12 col-sm-6 col-sm-push-6 col-md-5 col-md-push-7" id="PanelSecond">
       content for panel second goes here....
     </div> 
     <div class="panel  col-xs-12 col-sm-6 col-sm-pull-6 col-md-7 col-md-pull-5"  id="PanelFirst">
       content for panel first goes here...
     </div>
   </div>

To ensure that PanelSecond appears at the top, I have rearranged the HTML structure accordingly (following a mobile-first approach).

Use pull and push classes to adjust column alignment.

Alignment for large, medium, and small screens

https://i.sstatic.net/QbI80.jpg

For extra-small screens

https://i.sstatic.net/wf0py.jpg

Answer №2

To achieve the desired layout, switch the order of elements and use push & pull classes in columns of medium size:

Here is an example:

<div class="row equal">
  <div class="panel col-sm-6 col-sm-push-6 col-md-push-7 col-md-5" id="PanelSecond">
    Content for second panel goes here...
  </div>  
  <div class="panel col-sm-6 col-sm-pull-6 col-md-pull-5 col-md-7" id="PanelFirst">
    Content for first panel goes here...
  </div>  
</div>

For more information, visit: http://getbootstrap.com/css/#grid-column-ordering

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

Disabling transparency for divs and subsequently restoring it

Currently, I am in the process of developing a website dedicated to my hometown using Wordpress. To enhance the viewing experience for users, I adjusted the transparency of the main div so that they can fully appreciate the background image. While this mod ...

Utilizing Bootstrap for center-aligning a dropdown menu

I am using bootstrap to create a dropdown menu that I want to appear as a small box in the center of the page, similar to this example. Here is the HTML code I am working with: <div class="dropdown"> <button class="btn btn-default dropdown- ...

Attempting to align content in the middle of the page across all web browsers

I need assistance with centering all the content on my website across different screen sizes and browsers. Currently, everything appears off-center and aligned to the left on various screens I have tested. You can view the HTML and CSS code in this link. H ...

How can we use jQuery to extract an HTML element's external stylesheet and add it to its "style" attribute?

My goal is to extract all CSS references from an external stylesheet, such as <link rel="stylesheet" href="css/General.css">, and add them to the existing styling of each HTML element on my page (converting all CSS to inline). The reason for this re ...

Can the CSS file be modified while a MVC site is running?

My MVC website has a black and white color scheme with specific design elements in blue color. I handle all the coloring through CSS. I would like to change the color of these elements from blue to a different color occasionally. However, when using jQuer ...

What is the method for passing an element in Angular2 Typescript binding?

Is there a way to retrieve the specific HTML dom element passed through a binding in Angular? I'm having trouble figuring it out, so here is the relevant code snippet: donut-chart.html <div class="donut-chart" (donut)="$element"> ...

Remove information inside table cells <td> when the table is in edit mode by using JavaScript or jQuery

I am facing an issue where I need to clear the data in a HTML td onfocus, especially in an editable table using JQuery tabledit. The table is populated with data from a database and I want to be able to edit a td without having to manually delete the exist ...

How can I display only four decimal places by default within textboxes in HTML?

Looking for assistance with configuring textboxes in a cshtml file. The textboxes are bound to decimal fields in a view model and currently display nine zeros after the decimal point. I would like to limit the display to only four digits by default witho ...

Adjust the checkmark color of MUI Checkbox

When using Material UI's MUI library for React, I encountered an issue with the checkbox checkmark color. By default, the checkmark takes on the background color of the container element, which is great for light backgrounds but not ideal for dark one ...

When resetting a form, the styled radio buttons remain selected and do not deselect

I have a set of three styled radio buttons for car rental pickup locations: <div class="col-md-12 form-group"> <label for="car-rental-pickup-location" class="mb-2">Pickup Location<small class="text-danger">*</small></label>&l ...

Is there a way to incorporate HTML tags into an option?

Is there a way to include the <i></i> tags inside the <option></option> element? This is the current code I have: <option value="<?= $pages->ID ?>"><i class="<?=$icon?>"></i><?php echo get_the_t ...

Exploring the utilization of CSS DIV containers within the View Script

Within my layout script, I have defined specific CSS areas, such as: <div id="section-navigation"> Test </div> Is there a way for me to dynamically override these sections in my view script with different data? Below is an excerp ...

Am I incorrectly linking Javascript/CSS files/pages?

<script src="scripts/lib/angular.min.js"></script> <script src="scripts/lib/angular-route.min.js"></script> <script src="scripts/lib/angular-animate.min.js"></script> <script src="scripts/lib/jquery.min.js"></sc ...

Ways to achieve a consistent 2px border width across different browser zoom levels using CSS

Imagine you have two divs on a website: one with a 1px wide border and the other with a 2px wide border. Suddenly, when zooming below 100% (depending on various factors like browser and screen resolution), the 2px border div mysteriously transforms to loo ...

Separate a string into substrings based on the number of spaces it contains

My goal is to split a string into multiple parts based on spaces, resulting in an array with 3 values. For instance, if I have the string "SIZZLING STEAK TERIYAKI BOY" and divide it into 3 parts, the output should be ["SIZZLING STEAK", "TERIYAKI", "BOY"]; ...

I'm looking to position the vibrant red box at the bottom of the screen, right under the navigation bar. However, every time I try to

I'm struggling to align the full-screen red box under the navigation bar. I've tried using flex properties but it's not working as expected. My goal is to have the red box at 100% width and be responsive. Could it be something with my nav b ...

Pager.js utilizing Deferred Bindings

I am currently working on using Pager.js to develop a single page application. The structure I have set up is as follows: #word/definition #word/example #word/synonym This means that definition, example, and other elements are divs with page bindings: & ...

tips for choosing a specific dropdown menu item

I'm having an issue with a function that I want to apply to all my dropdown lists. The problem arises when I try to select an option from the second dropdown list - instead of displaying the correct value, it shows the value from the first group in th ...

Link to database stored in MySQL and HTML within a URL reference

I am currently working on creating an image link that allows users to define a folder in their settings. Below is the code I am using: <?php if (strpos($current_user_meta['UserRank'], 'Admiral ') !== false ) { // get the use ...

Tips for adjusting the width of a div when printing

Imagine I have two container elements named container1 and container2. First, I assign a width of 30% to container1 and 60% to container2. Then add a border between the two containers. However, when I attempt to print, container1 takes up the full 100% o ...