Switch up the order of columns by utilizing the push and pull features of Bootstrap

My layout consists of 3 columns arranged like this:

<div class="container-fluid">
  <h1>Hello World!</h1>
  <p>Resize the browser window to see the effect.</p>
  <div class="row">
    <div class="col-sm-3">left column</div>
    <div class="col-sm-6">center column</div>
    <div class="col-sm-3">right column</div>
  </div>
</div>

Now, I want to rearrange them using push and pull. The goal is to have the center column at the top, with the other columns having a size of 6 each.

Answer №1

When using bootstrap-3, it's important to remember that it is designed with a "mobile first" approach. This means that you should prioritize how your columns will look on small screens before considering larger ones.

For example:

  <div class="row">
    <div class="col-sm-6 bg-info col-sm-push-3">center column</div>
    <div class="col-sm-3 bg-success col-sm-pull-6">left column</div>
    <div class="col-sm-3 bg-danger">right column</div>
  </div>

It's important to also think about how these columns will display on different devices, but this should give you a good starting point.

Answer №2

I stumbled upon an excellent answer that could be of great help to you Enhancing column order with col-lg-push and col-lg-pull in Twitter Bootstrap 3

Bootstrap prioritizes mobile usability, so it's important to design your HTML with mobile devices in mind. Pushing and pulling elements is typically reserved for larger screens.

Answer №3

If you find yourself lacking content for certain screen sizes, a simple solution is to create two sections: one tailored for smaller screens and another for larger screens. This way, your layout remains visually appealing regardless of the device being used.

<div class="container-fluid">
  <h1>Hello World!</h1>
  <p>Resize the browser window to see the effect.</p>
  <div class="row hidden-sm">
    <div class="col-sm-3">left column</div>
    <div class="col-sm-6">center column</div>
    <div class="col-sm-3">right column</div>
  </div>
  <div class="row visible-sm">
    <div class="col-sm-12">center column</div>
    <div class="col-sm-6">left column</div>
    <div class="col-sm-6">right column</div>
  </div>
</div>

http://www.bootply.com/dUD8yYL0YP

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

Resolve Bootstrap columns with varying heights

My Bootstrap row contains a variable number of columns determined by a CMS, sometimes exceeding the space available on one line. I am looking for a way to neatly display all the columns with equal heights. <div class='row'> <div cl ...

Unable to hide table borders in ipython notebook in the usual manner

In the IPython notebook cell below, you will see a table with a gray background and borders: from IPython.display import HTML s=""" <style type="text/css"> table, td { border-collapse: collapse; border-style: hidden; background-color: ...

Discovering the font-weight attribute in Selenium IDE

Currently, I am working with Selenium IDE and aim to detect when a text element has the 'font-weight:bold' CSS property applied to it using 'verifyAttribute'. The specific CSS locator being used is: css=body.home.es ul#languages li:nt ...

Building pagination functionality in AngularJS by sending parameters to an AJAX service: A step-by-step guide

I'm looking to learn how to implement pagination on a page with 10 records per page. Despite my efforts in searching online, I haven't been able to find any helpful resources explaining this concept. I would greatly appreciate a simple example or ...

Adapting the top margin dynamically for different screen sizes

I am attempting to style an HTML DIV so that the margin-top is adjusted responsively based on the height of the div: jsfiddle Within the wrapper, there is another div that is initially set to display: none, but this may change if the user enters an incorr ...

How can you determine if the top of the window is the same as the top of any section while scrolling

I'm looking to dynamically add a class name "active" to sections on my webpage as I scroll down the page. I want to achieve this by checking if the window's top position is equal to any section's top position. Each section has a unique data- ...

Integrate PHP with cURL in a PhoneGap application

I have a PHP code with cURL and I am looking to display the result in my HTML5 app. <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.taringa.net/top/posts/?fecha=3&cat=-1'); curl_setopt($ch, CURLOPT_HEADER, false); curl_ ...

challenges encountered while using .css() to customize the height

Currently, I am working on a tutorial to learn about basic jQuery plugins. I am facing a challenge in understanding why my code is not adjusting the height of my <p></p>. The task requires creating a plugin that can set the height of specified ...

I would like to add an underline below the title

.thumb-text { position: absolute; width: fit-content; left: 50%; transform: translateX(-50%); } .thumb-text h3 { font-family: Georgia; font-size: 30px; color: black; font-weight: 900; } .thumb-text h3::after { content: ''; p ...

Angular Material's Expansion Panel Alignment

I am currently facing an issue with aligning the icon to the left side of the expansion panel and centering the title. I've tried using CSS with text-align but it's not working as expected. Any advice or suggestions would be greatly appreciated, ...

"By setting the HTML input box to read-only, the JavaScript button has the

Check out this js fiddle demonstration: http://jsfiddle.net/YD6PL/110/ Here is the HTML code snippet: <input type="text" value="a" readonly> <input type="text"> <input type="text"> <div> <button class="buttons">c</button ...

Seeking assistance with my personal portfolio project - any takers?

I'm facing an error on a coding challenge that says: "The height of the welcome section should be equal to the height of the viewport." I have set it to 100vh but I'm unsure how to resolve it. Here is the HTML code: <header> <nav id=& ...

Issue with the width on Mobile Safari

Encountering a strange problem with mobile Safari on iPads and iPhones where the body and some divs are getting cut off in the middle. Despite trying various solutions, I can't seem to fix it. The website works perfectly fine on desktop but not on mob ...

What could be causing my AngularJS to malfunction on this particular website?

I am currently learning AngularJs and practicing some coding. However, I am facing an issue where the javascript code does not work when I run it on my browser (Chrome/IE). The "{{product.like}}" code is not functioning as expected. Is there any specific d ...

Even if the width is not set to 100%, the div still breaks into a new row

Having an issue here. I'm working with 2 divs that should be displayed side by side. Both are enclosed in a div with max-width : n. I set width: 70% to the first div and width: 30% to the second div, expecting them to fully occupy the parent div. H ...

Why is my AngularJS application triggering two events with a single click?

<button id="voterListSearchButton" class="serachButton" ng-click="onSearchButton1Click()">find</button> This button allows users to search for specific information: $scope.onSearchButton1Click = function() { var partId = $("#partIdSearch" ...

Choose from a variety of components within a cell using xPath

Currently utilizing Behat to interact with form elements on a webpage. The structure of my HTML is as follows - I have a table with two required fields, one being an input, the other a textarea, and a checkbox. <table class="table"> <thead&g ...

What steps should I take to change the orientation of these items from vertical to horizontal display?

I'm struggling to get these items to appear horizontally (side by side) instead of vertically on my webpage. They are linked to a database, hence the PHP code included here. If you need more information, please feel free to ask. body { font: no ...

Curved edges on a text box featuring a scroll bar

I'm facing an issue with my website where I have a large amount of text in an html textarea that requires a scroll bar. The problem is, I'd like to add rounded corners to the textarea, but it doesn't look good with the scroll bar. Below is ...

Creating a dropdown menu that seamlessly populates elements without any empty spaces

My team at the company is using a menu created by another developer. I recently added a dropdown selection to the first item on the menu, but I've run into an issue where the dropdown box does not fully fill the item, and I can't seem to fix it. ...