Making absolute positioning responsive in Bootstrap 4 - a comprehensive guide

I am looking to enhance the responsiveness of my page, especially on smaller screens.

Currently, I have not utilized bootstrap for this purpose. I am contemplating whether I should use it or not. Can I utilize bootstrap for absolute positioning?

Thank you in advance for your assistance. I hope the question is clear with the provided drawings.

<div class="container-map">
    <div class="top-container">
        <div class="map-background">

        </div>
        <div class="map-filter">

        </div>
    </div>

    <div class="map-search-results">

    </div>
</div>

Below is the CSS code:

.top-container{
   height:100%;
   position:relative;
}

.map-background {
  z-index: 10;
  width: 100%;
  height: 100%;
}
.map-filter {
  z-index: 1000;
  top:5%;
  left:7%;
  min-height:50px;
  min-width:200px;
  position: absolute;
}
.map-search-results{
    width: 100%;
}

You can view the image here.

Desired layout shown in the image below:

You can check out the desired layout here.

Answer №1

This information could be beneficial.

   body, html{
      padding:0;
      margin:0;
    }
   .top-container{
   height:100%;
   position:relative;
}

.map-background {
  z-index: 10;
 width:100%;
 height: 500px;
  background:lightblue;
}
.map-filter {
  z-index: 1000;
  top:5%;
  left:7%;
  min-height:50px;
  min-width:200px;
  position: absolute;
  border:5px solid red;
}
.map-search-results{
    padding:20px;
    border:5px solid orange;
}
@media (max-width:767px){
  .map-filter{
    position: relative;
    left:0;
    top:0;
    margin-top: 20px;
    margin-bottom: 20px;
    padding:20px;
  }
}
  <div class="container-map">
      <div class="top-container">
          <div class="map-background">

          </div>
          <div class="map-filter">
            <h2>map filetr</h2>
          </div>
      </div>

      <div class="map-search-results">
        <h2>map search</h2>
      </div>
  </div>

Answer №2

* {
  margin: 0;
  padding: 0;
}

.map-bg {
  background: url('https://www.example.com/image.jpg');
  background-size: cover;
  padding: 100px 20px;
}

.key-results {
  padding: 40px 20px;
}

@media screen and (max-width: 767px) {
  .map-bg {
    background: none !important;
    padding: 40px 20px !important;
  }

}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<section class="map-bg">
  <div class="container">
    <div class="row">
      <div class="col-md-6 col-sm-12 col-lg-6 col-12">
          <p>
            What is Lorem Ipsum?
            <br>
            <br>
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
          </p>
      </div>
    </div>
  </div>
</section>
<section class="key-results">
  <div class="container">
    <div class="row">
      <div class="col-12">
          <p>
            What is Lorem Ipsum?
            <br>
            <br>
            Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
          </p>
      </div>
    </div>
  </div>
</section>
</body>
</html>

If you need that map background on small devices just remove the media query.. Hope it'd help :)

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

Creating a fixed sidebar on the left and right using Bootstrap 5

Is it possible to create a left and right fixed sidebar with content in the middle using two <nav> elements in Bootstrap 5 markup structure? Here's an example of what I mean: <nav> <div>left sidebar</div> </nav> <mai ...

Adjust the Bootstrap flex settings to display only 3 cards instead of the default 4 cards - HTML

We currently have a bootstrap setup that displays 4 horizontal scroll cards by default. However, we are looking to only show 3 cards in view and allow the 4th card to be viewed by scrolling. Code On mobile view, the code is still displaying 4 tiles even ...

Click to switch divs

I am struggling and in need of help. I have been trying to rotate divs on click using jQuery, which was successful until I had two sets of divs that needed to be rotated independently on the same page. When clicking on the arrows to rotate the content in t ...

How can I position a Button at the center of my Grid item using Material UI?

In my React 16.13.0 application, I am utilizing Material UI's Grid and trying to center the content of a button in the middle of a row. Here is what I have tried: center: { alignItems: "center", width: "100%", }, halfRow: { width: "5 ...

Reduce the distance between child items when utilizing the display flex with the space-between property

I have a container (100% width) with 3 buttons inside. I want to keep them evenly spaced with a small margin between each button. My attempt with Bootstrap and display flex with space-between didn't give me the desired result. https://i.sstatic.net/ ...

What is the best way to make a span's background color stretch to 100% width?

Is there a way to make the background of a span element stretch to the full width of its parent container? Just to Clarify I understand that using divs is an option, but it feels more like a workaround than a genuine solution to the issue. (di ...

What is the reason the default state of a checkbox does not show a background-color change, while the checked state does?

.checkbox__container { display: flex; flex-direction: row; align-items: center; padding: 0px; gap: 8px; & input[type="checkbox"] { box-sizing: border-box; width: 20px; height: 20px; accent-color: red; backgr ...

Exploring Bootstrap4: Interactive Checkboxes and Labels

My form design relies on Bootstrap, featuring a checkbox and an associated label. I aim to change the checkbox value by clicking on it and allow the label text to be edited by clicking on the label. The issue I'm facing is that both elements trigger t ...

Is there a way to dynamically assign the background color of a webpage based on the exact width and height of the user's screen?

I have customized the CSS of my website by setting the height to 800px and width to 1050px. Additionally, I have chosen a blue background-color for the body tag. It is important that the entire application adheres to these dimensions. However, when viewe ...

My JavaScript code runs perfectly fine on JSFiddle, but for some reason, it's not functioning correctly on

I need a solution where a new button is generated every time the post button is clicked, and each of these buttons should have its own counter. This works successfully in JSFiddle, but unfortunately doesn't work when I try to implement it elsewhere. ...

Firebase hosting adjusts the transparency of an element to 1% whenever it detects the presence of CSS opacity

I'm currently working on a website using Vue.js and Firebase. Everything runs smoothly locally, including a button with a desired low opacity. However, when I deploy the site to Firebase Hosting, the button's opacity inexplicably changes to 1% an ...

Media queries do not trigger the execution of CSS code

I am currently working on making a desktop-sized website responsive. However, I have encountered an issue where the CSS rule is being read by the browser but not executed, regardless of whether the media query rule is true or not. I have already included & ...

SB Admin 2 menu with multiple levels does not collapse as expected

I'm in the process of integrating the menu from the sb admin 2 template into my Ruby on Rails application: As I gradually added components to test functionality, I successfully implemented the top and side nav bars. However, I encountered an issue wi ...

Exploration of Non-height Divs

Repeatedly encountering the same issue - a fluid div with floated elements lacking a background due to having "no height." I've experimented with various solutions such as :after selectors, , and artificially setting a height, but none are particularl ...

Is it possible to locate an element using two attributes in C# WebDriver?

Can anyone assist me in finding elements based on their class and the text they contain? I have attempted the following methods without success, so any guidance would be greatly appreciated (I prefer using CSS for selection, but XPath is also acceptable): ...

The ellipsis text-overflow feature occasionally malfunctions during a single session when using IE 11

.show-ellipsis { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; } <div class="container"> <div class="row show-ellipsis"> {{record.bodyName}} </div> </div> My web application supports versions o ...

Tips for arranging images in a horizontal layout using FlatList in React Native

Is there a way to display feed images horizontally instead of vertically in FlatList? I've tried wrapping the images in a view with flex-direction set to row, as well as adding horizontal={true} to the FlatList, but nothing seems to work. Any suggesti ...

Two pictures, one adjusting in size and one staying the same size

I am working on a design with an 800px wide div that contains side-by-side images - one photo and one map. The challenge I am facing is that the map, which is 300px in width and has intricate details, becomes unusable when resized for smaller screens. I wa ...

Change the color of the Parent Menu when a childMenu is clicked on using CSS and HTML

<li class="btn-group" mdbDropdown> <a mdbDropdownToggle id="ParentId"> <i class="nav-item"></i> MainMenu <i class="fa fa-angle-down"></i> </a> <div class=" ...

Divided screen showcasing one movable panel

I am currently working on a design where I have a container with a specified maximum height. Inside this container, there are two separate divs. One of these divs (the footer) has a fixed height of 55px, while the other is a scrollable div that adjusts its ...