What is the best way to ensure that the positioning of the text adapts to

Whenever I adjust the screen size, the text in front of the slider moves. I utilized the grid system in Bootstrap 5.2 to position it. My goal is to keep the text in its original position relative to the carousel when changing the screen size. Here is my code snippet, what adjustments can be made to correct this behavior?

#text-position{
    
    position: absolute;
    width: 100%;
    color: white;
    z-index: 999;
}
.carousel-caption h1{
    font-size: 100px;
}
.btn-lg{
    width: 200px !important;
    position: absolute;
    width: 100%;
    z-index: 999;
}

.overlay { 
    color:#fff;
    position:absolute;
    z-index:12;
    top:500px;
    left:0;
    width:100%;
    text-align:center;
  }
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e5878a8a919691978495a5d0cbd7cbd5c887809184d4">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet"/>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
 <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="41232e2e35323533203101746f736f716c2324352070">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
 
 <main>
       <div id="slider" class="carousel slide" data-bs-ride="carousel">
         <div class="carousel-inner" >
           <div class="carousel-item active">
             <img src="images/hero1.png" class="d-block w-100" >
             
             
           </div>
           <div class="carousel-item ">
             <img src="images/hero2.jpg" class="d-block w-100" >
           </div>
           <div class="carousel-item ">
             <img src="images/hero3.jpg" class="d-block w-100" >
           </div>
         </div>
         <button class="carousel-control-prev" type="button" data-bs-target="#slider" data-bs-slide="prev">
          <span class="carousel-control-prev-icon" aria-hidden="true"></span>
           <span class="visually-hidden">Previous</span>
         </button>
         <button class="carousel-control-next" type="button" data-bs-target="#slider" data-bs-slide="next">
           <span class="carousel-control-next-icon" aria-hidden="true"></span>
           <span class="visually-hidden">Next</span>
         </button>
       </div>
       <div class="overlay">
        <div class="row">
         
      <div class="col-3 offset-1 "><h5>WE LOVE DESIGN</h5></div>
      
      </div>
      <div class="row">
        <div class="col-4 offset-1"><h1>CREATIVE MINDES</h1></div>
      </div>
      
      <div class="row">
        <div class="col-2 offset-1"><button type="button" class="btn btn-outline-light btn-lg " data-mdb-ripple-color="dark">GET IN TOUTCH</button></div>
      </div>
     </div>
 </main>

   
<script src="js/bootstrap.min.js"></script>

Check out how the website looks on a smaller screen.

Answer №1

Consider implementing the text position within your code:

.text-position{    
position: fixed;
width: 100%;
color: black;
z-index: 9999;
top: 50%;
right: 50%;}

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

Custom control unable to display MP3 file

Hey, I came across this awesome button that I am really interested in using: https://css-tricks.com/making-pure-css-playpause-button/ I'm currently facing two issues with it. First, I can't seem to play the sound. I've placed the mp3 file ...

Encountering a TypeError while attempting to utilize Django and Pandas for displaying data in an HTML format

import pandas as pd from django.shortcuts import render # Define the home view function def home(): # Read data from a CSV file and select only the 'name' column data = pd.read_csv("pandadjangoproject/nmdata.csv", nrows=11) only_city ...

Guide to create a sliding menu transition from the viewport to the header

I am just starting to learn jQuery and I want to create a menu similar to the one on this website Specifically, I would like the menu to slide down from the viewport to the header, as shown in the template in the link. I have searched through the jQuery ...

Implementing a jQuery method in a PHP page that is loaded through AJAX

I am facing an issue on my page where I am using jquery/ajax to load a series of buttons into a div. This script loads buttons every time the user scrolls the page and each button should run a jquery function when clicked. The problem arises when I switche ...

The footer fails to remain at the bottom of the page when there is limited content available

Despite searching extensively on Google, I have not been able to find a solution to this frequently asked question. My challenge is to consistently position the footer at the bottom of the page, even when there is minimal content present. Below is an exce ...

A Bootstrap carousel displaying images in a confused manner with another carousel on the same webpage

I recently encountered an issue with adding two Bootstrap 5 carousels on the same page. Even after assigning unique IDs to each carousel, the second carousel seems to mix photos with the first one, duplicating two photos from the previous slide. I tried ...

Setting a default value in an AngularJS form for a select dropdown menu

My goal is to develop an angularjs form with two fields - one text input and a select. The default setting should be a blank text input, but the select should have a preset value (the first element on the select list). I am following the guidelines in the ...

Unable to supersede the current CSS styling

I have implemented the example found here in my project and now I am trying to make the table stretch to fit the entire page. To achieve this, I have added the following CSS: html, body{ height: 100%; } #gridContainer { height: 100%; } table{ ...

Struggling to create a dynamic design for a nested column using bootstrap

After creating a layout in Figma, I have set up a grid structure as follows: <div class="container-fluid"> <div class="row" id="sobre-nos-wrapper"> <div class="col"> <div class="row"> <div class="col ...

What is the most effective way to switch between content in tabs using Bootstrap 5?

Can content in Bootstrap 5 tabs be toggled to close all tabs when clicking on an already open tab? Bootstrap documentation <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="62000d0d ...

Prevent ng-repeat from rendering the contents of my div

Currently, I am in the process of modifying a website for which I need AngularJS. I am trying to use the ng-repeat command to display some documentation on the site. However, whenever I add the ng-repeat within a div, it seems to "destroy" the layout and I ...

Organizing textual maps within a 2D array for rendering on an HTML5 Canvas

In my spare time, I am working on creating an HTML5 RPG game. The map is implemented using a <canvas> element with specific dimensions (512px width, 352px height | 16 tiles across, 11 tiles from top to bottom), and I'm wondering if there's ...

Trouble encountered in aligning two DIVs in a horizontal position

I have been through numerous discussions on the same problem, but none of the solutions seem to work in my case. I am currently working on a section of my website that has 3 small boxes, each containing an image on top and text below. The issue arises when ...

What is the process for converting an <input type="file> into a base64 string?

Currently, I'm attempting to send an image to my express backend by including the image directly in the post request body. var imgValue = document.getElementById("image").value; Within my post request: body : JSON.stringify({ image:imgValue ...

Ways to streamline repetitive CSS rules within media queries

As I work on defining multiple media queries, I realize there is some redundant code within them: @media only screen and (max-width:768px), only screen and (min-width:769px) and (max-width:1040px) { .list__figure { margin-right: 20px; ...

Please be aware that the website's loading speed may be slower than usual

Is it possible to notify a user that the website may take longer to load due to their slower internet connection? For example: Attention! It appears that the page is loading slowly because of your connection speed. Please be patient while the websi ...

Using JavaScript, you can add an article and section to your webpage

Currently, I am utilizing AJAX to showcase posts. My objective is to extract each property from a JSON object that is returned and generate an <article> for the title followed by a subsequent <section> for the content. While I can successfully ...

Failure of Highchart's resizing mechanism when hidden

Check out this AngularJS demo app featuring Highcharts: http://jsfiddle.net/dennismadsen/dpw8b8vv/1/ <div ng-app="myapp"> <div ng-controller="myctrl"> <button ng-click="hideView()">1. Hide</button> <button ng ...

Adding HTML saved as a blob directly to the source of a .aspx page

I am faced with the task of creating a page that allows users to edit content, which will then be converted to HTML and stored in an MS SQL 2008 R2 database. The challenge is to display this information on an announcements page using the data from the data ...

What are some ways to prevent pinch zoom on an HTML webpage?

Searching for a way to disable pinch-to-zoom on an HTML web page has proven to be a daunting task. Despite numerous attempts, I have yet to find a solution that works. I am reaching out in the hopes that you may have the answer. Some of the methods I have ...