Positioning columns in Bootstrap with a fixed layout

Is there a way to troubleshoot issues with Bootstrap col?

I attempted the following solution, but it's not yielding the desired outcome:

<div class="row">
    <div class="col-md-6">Content goes here...</div> 
    <div class="col-md-6" style=" position: fixed">Content goes here...</div> 
</div>

fixed positioning causes the col to act like an absolute position.

Also, I'm wondering how I can deactivate a fixed position when the page is scrolled down 400 pixels from the top.

Answer №1

To ensure the fixed position is only applied above a specific screen width, utilize media queries. For instance, if we consider 768px as the Bootstrap 4 md breakpoint:

CSS (you may include min-height):

@media (min-width: 768px) {
    .fixed-posi {
        width: 50%;
        margin-left: 50%;
        min-height:100%;
        position:fixed;
    }
}

Next, integrate fixed-posi in your layout like this...

<div class="row">
    <div class="col-md-6">
       Insert content here...
    </div>
    <div class="col-md-6 fixed-posi">Insert content here... (with fixed position)
    </div>
</div>

See the demo here:

For a related query on fixing a DIV to the left: How to have a fixed left column with a scrollable right side in Bootstrap 4 responsive design?

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

What is the best way to eliminate the white margin that is showing up on the right side of my website?

Here's a question that has been bugging me recently... So, I've been working on creating my own version of an Airbnb website called 'tombnb' for a few weeks now. Everything was going smoothly until I encountered a persistent issue. Th ...

What could be causing the last LI to drop onto a new line when floating UL to the right?

I'm currently working on creating a horizontal navigation that needs to align to the right side of the page. However, when I float the navigation to the right and then float all the list items to the left, the last item in the list breaks onto a new l ...

Tips for concealing a Bootstrap modal during the show.bs.modal event

Check out this code snippet: let order_modal = document.getElementById('order'); order_modal.addEventListener('show.bs.modal', function (e) { bootstrap.Modal.getInstance(order_modal).hide(); }, false); Upon opening the modal, the ...

Clicking on a link with JQuery does not fire the action when the href attribute is set to "#open-site"

My navigation setup is as follows: <ul> <li><a href="index.html#open-site">Test</a></li> <li><a href="#open-site">Test</a></li> <li><a href="test.html#open-site"> ...

Photo positioned on top of the form with Bootstrap 5

I am working on creating a responsive webpage using Bootstrap, where I need to display a large image above a form. To manage the size of the image, I have placed it inside a "peek-view" container which allows scrolling both horizontally and vertically to v ...

Is it possible to apply a :before or :after pseudo-element to an input field element?

I'm having trouble incorporating the :after CSS pseudo-element on an input field. It seems to be working fine with a span, but not with the input field. <style type="text/css"> .mystyle:after {content:url(smiley.gif);} .mystyle {color:red;} < ...

There is zero gutter in Bootstrap

Is it possible to use the bootstrap grid system without any gutters? I want to have 3 columns in one row like this: http://prntscr.com/6gpmhm. I have shared the markup for the CSS I am using, which is the default CSS of the framework. <section class ...

What is the best way to center my navbar logo and have the navigation links encapsulate it on either side?

I am looking to achieve a design where my navbar brand is centered with the navigation links positioned on the left and right of it. When the screen size reaches md, I want the nav links to disappear into a burger menu while still keeping the nav brand vis ...

Tips on altering button color when input field is populated

I have been researching online and have not come across any discussions on how to dynamically change the color of a button in JavaScript when an input field is filled. I haven't really tried any code myself because there are very limited resources add ...

how to dynamically update a button's text using Vue.js

I have a challenge where I need to dynamically change the text of a button based on whether a value is true or false. Below is the code snippet that I have been working on: <button class="btn btn-primary table-button" type="button&quo ...

Tips for customizing the appearance of the React Native side menu

After successfully implementing a side menu using react native, I am now looking to style the image to match the design shown in the links below: Check out the application I developed I want it to look like this Is styling the key to achieving this desi ...

JavaScript programming does not rely on using the onclick method to style HTML elements

For a recent project, I was tasked with creating a toggle-style button setup for the challenge on CodePen. To achieve a 3D appearance for the button, I wrote some JavaScript code that utilized the onclick event. var on = true const green = document.getElem ...

Tips for organizing SQL queries in a grid layout

I have a database table called People in SQL and I am displaying the names of people from this table on my website. Each name is represented as a column in the People table. My goal is to arrange these names in a grid layout, similar to a table, but with ...

What is the best way to organize a form's checkboxes into an array using Node.js?

My goal is to design a form with multiple checkboxes where each checkbox has the same name, and only the selected values are submitted with the form. While I know how to achieve this using PHP as demonstrated in this SO question, I am facing difficulty imp ...

The CSS3 :empty selector targets elements that have no content inside

Seeking guidance on CSS3 and the :empty pseudo-class. Currently developing a web AJAX application with a sidebar in the layout that I want to hide when empty. Here's what I have: #my_sidebar:empty { display:none;} To display it when not empty, I wr ...

Ways to enhance HTML styling using htm.fromHtml() on Java (Android)

Here is the HTML code for my webpage: <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> </head> <style ...

Creating interactive images with text overlays using HTML5 and JavaScript Canvas on user click

Hello StackOverflow community! I'm a newcomer to JavaScript programming and currently facing some challenges with the HTML5/JavaScript Canvas Combo. I have a button that, when clicked, is supposed to verify certain lines and then display an image (pr ...

Tips for expanding a fabric canvas to match the entire width of its parent division

specific scenario I have a cloth canvas placed inside a main section. How can I expand the canvas to cover the entire width and height of its container? Here is what my current code looks like: <div class="design_editor_div"> &l ...

The sub-menu is being obscured by a PDF element in Internet Explorer, causing visibility issues

I have an object type tag on my page that displays a PDF file. Everything is functioning correctly, but in Internet Explorer, my sub-menu is being hidden behind the object tag. var objTag = $('<object></object>') .attr({ data: source ...

Struggling to find your way around the header on my website? Let me give

I'm looking to display certain links prominently at the top of a page, similar to this example: "home > page1 > link1 > article 1." Can someone advise on how to achieve this using HTML, PHP, or jQuery? ...