Sorting Bootstrap Columns

Struggling to rearrange the bootstrap columns with helpful links in a row alongside an empty div and Lorem Ipsum text that spans 12 columns. I have attempted using clearfix and different column sizes, but none of them seem to be effective.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

<div class="container">
  <div class="row">

    <!--Links-->
    <div id="content-left" class="col-xs-10 col-sm-10 col-md-4 col-md-offset-0">
      <h2>Useful Links</h2>
      <ul>
        <li><a href="#">Link 1 Title</a></li>
        <li><a href="#">Link 2 Title</a></li>
        <li><a href="#">Link 3 Title</a></li>
        <li><a href="#">Link 4 Title</a></li>
      </ul>   
    </div>
    <!--Links close-->
    
    <div class="clearfix"></div>
    
    <!--Content-->
    <div id="content-right" class="col-xs-10 col-sm-10 col-md-12 col-md-push-0">
      <h2>Content</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
      <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
      <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p>  
    </div>
    <!--Content close-->
    
    <!--Twitter-->
    <div id="content-left" class="col-xs-10 col-sm-10 col-md-6 col-md-pull-6">
      <h2>Twitter</h2>
    </div> 
    <!--Twitter close-->

  </div><!-- row close -->
</div>

Answer №1

  1. Both the blocks with IDs links and twitter have been assigned the same ID content-left, which is incorrect. IDs should be unique.

  2. To resolve this issue, you can enclose links and content within an additional block and use negative margins on the content.

Note: This solution is effective as long as the height of the twitter block does not exceed the height of the links block.

Please review the following code snippet:

#block-links   { background-color: #9fc; }
#block-content { background-color: #ff9; }
#block-twitter { background-color: #fc9; }

@media (min-width: 992px) {
  #block-content {
    margin-right: -200%;
    width: 300% !important;
  }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

<div class="container">
  <div class="row">

    <!-- Additional block -->
    <div class="col-xs-10 col-md-4">
      <div class="row">

        <!--Links-->
        <div id="block-links" class="col-xs-12">
          <h2>Useful Links</h2>
          <ul>
            <li><a href="#">Link 1 Title</a></li>
            <li><a href="#">Link 2 Title</a></li>
            <li><a href="#">Link 3 Title</a></li>
            <li><a href="#">Link 4 Title</a></li>
          </ul>   
        </div>
        
        <!--Content-->
        <div id="block-content" class="col-xs-12">
          <h2>Content</h2>
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </p>
          <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </p>
          <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </p>  
        </div>
    
      </div>
    </div>
    
    <!--Twitter-->
    <div id="block-twitter" class="col-xs-10 col-md-6 col-md-offset-2">
      <h2>Twitter</h2>
    </div> 

  </div>
</div>

Answer №2

One way to effectively manage this issue is by using the pull and push technique. However, it's important to note that this method only works within the same row as it assigns the left and right properties without creating a new row. A workaround that I often employ involves duplicating the Twitter div section like this:

<div class="col-md-6 col-sm-12">
  <!-- Links -->
</div>
<div class="col-md-6 hidden-sm hidden-xs">
  <!-- Twitter -->
</div>
<div class="col-sm-12">
  <!-- Content -->
</div>
<div class="col-sm-12 hidden-md hidden-lg">
  <!-- Twitter -->
</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

Is there a method in AngularJS to automatically set app.comment to null if the point is not equal to 1 using front end logic?

Can we verify on the front end in AngularJS if app.point !=1 and app.comment==null? <td> <input type="number" max="5" min="1" ng-init="app.point=5" data-ng-model="app.point"> </td> < ...

Responsive Bootstrap 4 columns

I'm currently working with Bootstrap and encountering some issues with the responsive layout of my website. I have 2 rows with 4 columns in each row, structured like this: setup-1 Here is the code snippet: <div class="container"> <div c ...

Capturing and saving location data without internet connection, and then displaying markers once connectivity is restored

I am currently developing a web application that will monitor the user's location. I want to ensure its reliability, so even if the user loses internet connection, the application will continue tracking their location (since GPS does not rely on inter ...

Navigation menu with collapsible horizontal sub-menu display toggle

I have set up a test page using Bootstrap 4.3.1 to create a menu bar with submenus. The menu should display a triangle pointer when hovered over, indicating the selection. The user should be able to move the mouse to the submenu bar to choose a submenu. Wh ...

The code seems to be malfunctioning in a separate JS file, but oddly enough, it functions properly when placed within a <script> tag

I am trying to create a loader, but I have encountered an issue where the script works when placed directly in the HTML file, but not when it is in a separate JavaScript file. Here is the script: var loader = document.getElementById("ld"); w ...

Define the iframe height as "100% minus X pixels"

Is there a way to trim the bottom area of an external iframe that I want to embed on my website? The iframe contains links that cannot be edited, leading to pages with different sizes. My aim is to achieve something similar to <iframe height:100%-20px ...

Unable to transfer all the formatting from the original file for the window.print() function. Localhost is functioning properly, but encountering issues with production

I'm encountering an issue with getting all styles from my Vue app. I have tried the code provided in this answer: https://stackoverflow.com/questions/52343006/how-to-print-a-part-of-a-vue-component-without-losing-the-style While it works fine on loc ...

A guide to accessing and managing events for the child inside a div element using extjs4

How can I dynamically switch between the divs with classes "icon-right" and "icon-left" when clicked? Here is an example of the HTML and ExtJS code involved: Html code: <div class="msg"> <div> <div cla ...

Is there a way to eliminate a CSS class from a div element within the outcome of an ajax response?

My ajax response is functioning properly and displaying the content of the result, but I am always getting the CSS effects which I do not want. I need to eliminate the class="container body-content" from the following div in the ajax call's result. ...

Targeting HTML tags, styling names, and class names using CSS

In the markup below, I am trying to target three specific points using CSS. img style*=right class=media-element I attempted to use the code below, which did not work: img[style*="right"][class="media-element"] {margin-left:10px;} However, selecting t ...

Child absolute div is getting cropped due to overflow auto of parent absolute div

I am facing an issue with a div that is absolutely positioned within another div with overflow set to auto. The problem is that the child div is being cut off due to the overflow. I want the child div to break free from the container div, similar to how it ...

The horizontal display list is experiencing issues when using the display inline property

I'm having trouble getting my list to display horizontally. I've tried using display: inline, as well as float: left; and position:center, but can't seem to get it centered properly. JavaScript Array.prototype.map.call(document.querySelect ...

Upon clicking the collapse button, the collapsed element briefly appears before its height value is reset to empty in the element's style

Check out this code snippet: <!-- Expand buttons --> <div> <a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExa ...

Tips on avoiding the collapse of the right div when positioned under a left float in a full page layout

Trying out a full page layout for the first time, with a left div serving as a block style nav. #admin_nav { width: 230px; height: 100%; background-color: #f9f9f9; border-right: 1px solid #ddd; float: left; } The content is on the rig ...

Phonegap's JavaScript canvas feature is experiencing issues

Recently, I came across a JavaScript bouncing ball animation that works perfectly on the Chrome browser when used on a PC. However, when I tried running it using Phonegap Eclipse Android emulator, I encountered an issue where the canvas appeared blank and ...

HTML automatically removes added elements

I have embarked on the journey of developing a task management application. The main functionality I am working on involves appending a new event card to the events div when the submit button of the formlayer is clicked. function reveal() { document.g ...

Is one round the limit for my JavaScript image slider?

After studying the JavaScript Chapter on W3Schools, I attempted to create an image slider. Initially, everything worked perfectly for the first cycle. For instance, when I clicked the next button, the slides continued to slide until the end of the slidesho ...

Setting CSS attributes based on the parent node: What you need to know

Here is my CSS code snippet: .over_center { position:absolute; top: 50%; left:50%; height: 160px; /* two thirds (2/3) of parent size */ width: 160px; /* two thirds (2/3) of parent size */ margin-top: -80px; /* negative one third of parent size */ margin-l ...

Issues with Windows font rendering when using @font-face in CSS

Encountering issues with @font-face on Windows computers, regardless of the browser used. The fonts display properly on Linux and OSX. Below is the CSS code I'm currently using (generated with font-squirel) Review the screenshots for the identified ...

What could be the reason behind the occurrence of an error after deleting certain lines of code

The code below is functioning correctly. obj = { go: function() { alert(this) } } obj.go(); // object (obj.go)(); // object (a = obj.go)(); // window (0 || obj.go)(); // window However, an error arises when I comment out the first two lines. obj ...