Can someone guide me on the process of creating responsive text overlay on an image using Bootstrap 4?

Seeking a solution for making the letters inside an image responsive without using media queries, only utilizing Bootstrap grid. Currently, when resizing the screen, the letters overlap each other instead of maintaining their proportions. Below is the CSS code used for positioning the text within the image:

.banner{
    position: relative;
}
.heading-annual{
    position: absolute;
    top: 10%;
    color: whitesmoke;
    left: 7%;
}
.heading-medicine{
    position: absolute;
    top: 25%;
    color: whitesmoke;
    left: 7%;
}
.heading-manchester{
    position: absolute;
    top: 43%;
    color: whitesmoke;
    left: 7%;
}
.heading-date{
    position: absolute;
    top: 55%;
    color: whitesmoke;
    left: 7%;
}
<div class="container-fluid px-0">
        <div class="row">
            <div class="col-md-12 col-lg-12 banner">
                <img src="https://rcpmedicine.co.uk/wp-content/uploads/2018/11/new_banner_home.png" height="100%" width="100%" >
            </div>
        </div>
    </div>
    <h1 class="heading-annual">RCP annual conference</h1>
    <h1 class="heading-medicine">Medicine 2019</h1>
    <h4 class="heading-manchester">Manchester Central</h4>
    <h4 class="heading-date">25-26 April 2019</h4>

Answer №1

Have you considered using a background image instead of an img tag?

Here is an alternative approach:

.banner {
  min-height: 500px;
  display: flex;
  align-items: center;
  background-image: url(https://rcpmedicine.co.uk/wp-content/uploads/2018/11/new_banner_home.png);
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  padding: 50px;
  color: white;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<div class="container-fluid banner">
        <div class="row">
            <div class="col-md-12 col-lg-12 ">
                <h1 class="heading-annual">RCP annual conference</h1>
                <h1 class="heading-medicine">Medicine 2019</h1>
                <h4 class="heading-manchester">Manchester Central</h4>
                <h4 class="heading-date">25-26 April 2019</h4>
            </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

Create a layout where a flexbox container is nested under another div and achieve the desired positioning

<style> .container{ display: flex; gap: 5px; flex-direction: row; justify-content: space-around; flex-wrap: wrap; overflow:auto; } .container .one{ background-color: blue; ...

Is there a way to turn off vue.js transitions specifically for testing purposes?

I'm utilizing a vue.js component with the <transition> element for show/hide animations. However, I want to disable the animation for faster testing. How can I achieve this? The solution proposed is * { transition: none !important } in this lin ...

Is it recommended to employ @media print for a webpage dedicated exclusively to printing purposes?

Imagine a scenario where I have a specific page featuring a print button. Clicking on this button redirects me to a separate page with the same content, optimized for printing purposes. Instead of using @media print directly on the original page due to n ...

UI experiencing issues with selecting radio buttons

When trying to select a radio button, I am facing an issue where they are not appearing on the UI. Although the buttons can be clicked, triggering a function on click, the selected option is not displayed visually. <div data-ng-repeat="flagInfo in avai ...

React component for a background image with a gradient overlay

I'm facing an issue trying to incorporate a background image for a div along with a color overlay. In plain CSS, the code would typically look like this: .backgroundImage { background-image: linear-gradient(to bottom, rgba(245, 246, 252, 0.52), rg ...

The alignment of image and text next to each other is not functioning as intended

I've been attempting to display an image and text next to each other, but I'm encountering some issues. The current output looks like the figure below: https://i.stack.imgur.com/WxxrS.jpg The desired layout is as shown in the following link: ht ...

Creating a diagonal division within a rectangle using CSS

My goal is to create a rectangular div that sits behind a video, with a rotation of 35 degrees using CSS. Additionally, I aim to make the design responsive to different screen sizes. ...

Trouble arising when implementing media queries alongside jQuery

When the screen size is 768px, I need to trigger the code below by clicking on the next button. However, an issue arises when trying to revert back to the original style after changing the screen size: $(document).ready(function() { alert(); $ ...

Electron fails to display images in the compiled version

I'm currently troubleshooting an issue related to displaying images using CSS in my electron project. In the latest version of the application, the images are not showing up when linked from a CSS file. However, in a previous version, the images disp ...

React animation failing to render underline animation

After tinkering with the underline animation while scrolling down on Codepen using Javascript, I successfully implemented it. You can check out the working version on Codepen. This animation utilizes Intersection Observer and a generated svg for the underl ...

Remove the whitespace between the <h2> element and the CSS animation

Is there a way to remove the space between h2 and the animation in the following code snippet? .loader { border: 16px solid #f3f3f3; border-radius: 50%; border-top: 16px solid #3498db; width: 50px; height: 50px; -webkit-animation: spin 2s li ...

What is the functionality behind this unique SCSS mixin that combines flexbox and grid layouts?

Discover a SCSS mixin for creating flexbox/grid layouts HERE. Take a look at the complete mixin code below: @mixin grid-col( $col: null, $grid-columns: 12, $col-offset: null, $gutter: null, $condensed: false, ...

Slider - incorporating a heading onto a video with HTML styling

Is there a way to display a title on a slider when one of the slides contains a video? Here is an example code snippet: <!-- Swiper--> <div data-height="100vh" data-min-height="480px" data-slide-effect="fade" class="swiper-container swiper-s ...

Looking to design this chart using CSS and HTML?

Could someone please help me with resizing the circle border in this code? I am facing difficulties adjusting the size and would appreciate any assistance. By running the code snippet, you can see the issue I am encountering and how it differs from the pro ...

Modify just one of the padding axis while keeping the other constant by utilizing a media query

My div currently has the following padding set: padding: 14px 150px; I want to change the left/right padding without affecting the top/bottom padding using a media query. @media screen and (max-width: 700px){ #paddingDiv{ padding: same as ...

How can a fixed size block and a responsive block be aligned next to each other?

I am looking to create a centered table that is 900px wide with one row and two cells. The right cell should always be 200px wide, while the left cell should fill up the remaining space. However, I am facing an issue where the right cell jumps below the le ...

How to Apply CSS Class When Hovering in CSS

Is it possible for an HTML element to automatically inherit properties of a pre-written CSS class when I hover over it, without using Javascript? ...

A JavaScript or CSS file within an HTML document

I understand this may seem like a silly question. However, out of curiosity, is there a way to upload an HTML file (with a .html extension) as a JavaScript or CSS file (renamed with a .js or .css extension), specifying the type header as either HTML or js ...

Ways to implement a transition effect when the hover state is deactivated or no longer present

After applying a transition to the header using the hover pseudo-class, I noticed that it abruptly snaps back to its original position when the hover effect is removed. Is there a way to smoothly return the header to its original position using the same ...

Am I on the right track in my understanding of how document and viewport relate to mouse position in JavaScript?

After reviewing responses from a previous inquiry, it is evident that both pertain to the x and y coordinates of mouse positions. In relation to the document and In relation to the viewport. I have delved into an article on QuirksMode, yet I feel ther ...