Structure of Divs with Bootstrap

Looking to create a layout with two divs side by side like the image below: Example

However, when the screen width increases, the layout changes to this: Current Here is the code:
Is there anyone skilled in this area who can guide me through it? Your assistance is greatly appreciated.

  .Frank-row
        {
            border: 2px solid green;
        }
        
        .Frank-left
        {
            border: 2px dotted red;
        }
        
        .Frank-right
        {
            border: 2px dotted orange;
        }
<div class="container-fluid" >
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 Frank-row" >
                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 Frank-left" >
                    <p>left</p>
                    <p>left</p>
                    <p>left</p>
                    <p>left</p>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 col-offset-sm-6 col-md-offset-6 col-lg-offset-6 Frank-right" >
                    <p>right</p>
                    <p>right</p>
                    <p>right</p>
                    <p>right</p>
                </div>
            </div>
        </div>
    </div>

Answer №1

There are a couple of things to address here. Firstly, the wrapper div is unnecessary for achieving this layout.

Additionally, the offset classes on the div were causing it to move to the next line. By removing these classes, the layout issue has been resolved.

You can view an example here

Answer №2

Simply omit the col-offset section!

.Frank-row {
  border: 2px solid green;
}

.Frank-left {
  border: 2px dotted red;
}

.Frank-right {
  border: 2px dotted orange;
}
<div class="container-fluid">
  <div class="row">
    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 Frank-left">
      <p>left</p>
      <p>left</p>
      <p>left</p>
      <p>left</p>
    </div>
    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 Frank-right">
      <p>right</p>
      <p>right</p>
      <p>right</p>
      <p>right</p>
    </div>
  </div>
</div>

For a demo on resizing, check out: https://jsfiddle.net/xt41kj6j/

Answer №3

Ensure that you have included bootstrap.css in your file. Also, make sure to remove the col-xs-12 class from two divs within the Frank-row div. This is necessary because the col-xs-12 class takes precedence over other col-** class css values.

<div class="container-fluid">
  <div class="row">
    <div class="col-sm-6 col-md-6 col-lg-6 Frank-left">
      <p>left</p>
      <p>left</p>
      <p>left</p>
      <p>left</p>
    </div>
    <div class="col-sm-6 col-md-6 col-lg-6 Frank-right">
      <p>right</p>
      <p>right</p>
      <p>right</p>
      <p>right</p>
    </div>
  </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

Having trouble getting the JavaScript function to run when clicking a button inside a div or form?

Hey there, so I've got this scenario where I have a button nestled within a div. Take a look at the HTML snippet below: <div class="row"> <button type="button" id="submit">Send</button> </div> Prior to this button, there ...

Can a small white pop-up be triggered by clicking a button?

While exploring the website , I noticed that clicking on Availability Zones opens a small window with text on the right side of the page. Is it possible to achieve a similar feature on a leaflet map without using JavaScript? This functionality would be tri ...

Using Javascript to dynamically enable or disable an input field depending on the choice made in another field

I attempted to implement the solution provided in this answer for my code: How do I disable input field when certain select list value is picked but unfortunately, it is not working as expected. The scenario involves an HTML select field with the ID &apos ...

Location-based services: Updating the position of a Google Maps marker without refreshing the entire map interface

How can I update only the marker on a map when the device is in motion or has increased accuracy? I want to reload the map when the position changes, but only move the marker. Below is the code snippet that I currently have: if (navigator.geolocation) { ...

The pattern() and onkeyup() functions are unable to function simultaneously

When trying to display a certain password pattern using regex while typing in the fields, I encountered a problem. The onkeyup() function works for checking if both passwords match, but it causes the pattern info box not to appear anymore. I'm curiou ...

Tips for capitalizing the first letter of a directory

I want to automatically convert all directories in the URI to lowercase if the user types them in uppercase. For example, https://example.com/hOmE should be converted to https://example.com/home. ...

Mixing together an array of colors, experimenting with adding a touch of transparency

Here is my first question, diving right in. I recently created a canvas in HTML and followed a tutorial to generate random floating circles that interact with the mouse position......if you want to check it out, click here. The issue I'm facing now ...

Issue: The component factory for GoogleCardLayout2 cannot be located

Recently I've been working on an Ionic 3 with Angular 6 template app where I encountered an issue while trying to redirect the user to another page upon click. The error message that keeps popping up is: Uncaught (in promise): Error: No component fac ...

Tips on looping through a universal array and retrieving user input

My current project involves creating a news site using the Guardian API. I want to implement a search feature that allows users to input keywords and retrieve the webTitle attribute for matching elements. While I could simply insert the user input directly ...

Issue with ASP.NET Base64 image source rendering incorrectly

After retrieving a Base64 string from Azure active directory using a Lambda function, which represents a user's profile picture, I am facing issues displaying it on an ASP.NET page. Below is the code snippet in ASP.NET (The referenced HTML object is ...

Delete the designated column from the table

I am having difficulty with hiding and showing table columns using checkboxes. I need to eliminate the Mars column (in bold) along with its corresponding data (also in bold). Once the Mars column is removed, I want the Venus column and its data values to ...

Tips for displaying a Bootstrap 4 table on smaller screens

I have a Bootstrap 4 table filled with JSON data. The table renders perfectly on the UI, but users on smaller devices must scroll to view all the data. Despite there not being much data in the HTML table, users still need to scroll on small devices. I wa ...

How can we effectively transform an HTML opening and closing tag into a function?

Dealing with a complex HTML tag can be challenging, especially when it appears in various parts of the code. For instance: <div class="blabla" data-test="blablabla" ... data-another-attribute="blabla" > <some complex html code ... > </ ...

Various colored backgrounds in a random arrangement on a grid post layout

I'm looking to implement this plugin for displaying blog posts, but instead of using an image as the background, my client wants different colored images. I have managed to figure out the code to achieve this based on a post I found here, but unfortun ...

The button's color cannot be modified due to a malfunctioning event script that is not

Seeking an explanation for why my current implementation isn't working. I'm attempting to create a quiz with a multiple choice section where the correct answer turns green when clicked, and incorrect answers turn red. Despite validating the code ...

Spinning a CSS object around an axis

Trying to add a unique touch to my image rotation with CSS. While familiar with rotating around x, y, and z axis, I want to achieve a diagonal rotation this time. Wondering if there's a way to tweak the y axis for a more slanted effect on my image? ...

Enhanced jQuery Embed Code validation for user input using a textarea

Currently, I am developing a website that allows users to input embed codes from popular platforms such as Twitter, YouTube, Instagram, Facebook, and so on. The embed code undergoes validation checks and is saved if it meets the criteria. However, when us ...

Steps for positioning an element to the left and center of a div

I'm having trouble aligning my two elements in a simple horizontal menu to the middle left. I want them to have a margin of 5px on the left and right sides. Here is a screenshot and CSS style: https://i.stack.imgur.com/vzO5D.png .body_clr { wid ...

Tips for centering links in the navigation bar on Bootstrap 5 when viewing in a small size

I had previously inquired about customizing the Bootstrap 5 navbar in this post: Adjust navbar height to be smaller and I received some helpful answers. Thank you to everyone who responded. However, I now have a follow-up question: I am interested in ch ...

Utilizing a switch to deactivate all currently active classes on individual div elements

I'm currently facing an issue with implementing a toggle feature in a particle manner. I have three divs with onclick events and each has a toggle CSS class. My goal is to ensure that when one div is clicked, if the others are active, they revert back ...