How to overlay an image on a div element using Bootstrap styling

My goal is to have an image positioned between two separate div tags similar to a Facebook profile page:

https://i.sstatic.net/sBocE.jpg

I have tried solutions found here but they didn't work as expected. The image position changes when the screen size decreases due to Bootstrap's responsiveness, which is not what I want.

Below is the code I used for testing (which may not be perfect) -

HTML -

<div class="container">
        <div class="jumbotron jumbo" id="custjumbo">
            <h1>This is a jumbotron... </h1>
            <h2>Let's see what can we make of it..</h2>

            <br>

            <img src="images/tiger.jpg" class="img-thumbnail" alt="Tiger" 
            width="304" height="236">
        </div>
</div>

The CSS -

.container {
    background-color: cadetblue;

    }

    .jumbo {

    margin-top:20px;
    position: relative;
    }
    .img-thumbnail {
    position: absolute;
    bottom: -60px;
    right: 200px;
}
    img {
    display: block;
    width: 200px;
    height: 200px;
    background: green;
    }

This is the result I achieved:

https://i.sstatic.net/PIOmu.png

Answer №1

One alternative to using absolute positioning for repositioning an image is changing the img-thumbnail to position: relative and setting 'bottom: -60px'. This can achieve the desired effect without relying on absolute positioning.

Answer №2

verify

.container {
    background-color: cadetblue;
    width:100%;

    }

    .jumbo {

    margin-top:20px;
    position: relative;
    }
    .img-thumbnail {
    position: absolute;
    bottom: -90px;
    left:15%;
}
    img {
    display: block;
    width: 200px;
    height: 200px;
    background: green;
    }
    .bottom-div {
    height:200px;
    background-color:red;}
<head>
<meta name="viewport" content="width=device-width, initial-sclae=1">
</head>
<div class="container">
        <div class="jumbotron jumbo" id="custjumbo">
            <h1>This is a jumbotron... </h1>
            <h2>Let's see what can we make of it..</h2>

            <br>

            <img src="images/tiger.jpg" class="img-thumbnail" alt="Tiger" 
            width="304" height="236">

        </div>
                    <div class="bottom-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

Update the style of elements on each iteration in Symfony2

I have implemented a collapsible CSS page for FAQs. While static text works fine, I am fetching questions and answers from the database which is causing an issue. In its standard CSS version, the collapsible FAQ appears as follows: <div clas ...

Transforming HTML 'img' elements into React components without losing styling: How do I achieve this with html-to-react?

I am seeking guidance regarding the usage of the html-to-react library. Consider the following html string: '<div> <img src="test.png" style="width: 100px;"/> <img src="test2.png" style="margin: 0px 4px;"/> </div>' ...

Utilizing Timer Control for Image Rotation in Presentations

I have two sets of images named Div1 and Div2 that need to be displayed in a slideshow. The condition is as follows: For the first seven days, I want the images from the first set, Div1, to appear in the slideshow. Once the seven days are over, the images ...

How can I place this ribbon on top of an image in an HTML email to ensure it displays correctly on email clients such as Outlook?

As I delve into my research, it's becoming apparent that achieving this result might not be feasible across all email clients. However, I'm curious to know if there have been any recent developments in the email world that would allow me to repli ...

Submitting a form using only input buttons to transfer parameters to an Action in ASP.NET Core

Currently, I am working on my thesis and developing a simple browser game. My project involves having a form with three buttons that need to trigger the same action with different parameters. Here is what I have come up with so far: @using (Html.BeginForm ...

What is the best method to retrieve particular HTML lines (containing a flex container) with IronPython?

Utilizing IronPython 2.7.9.0 in Grasshopper and Rhino, I am extracting data through web scraping from a specific widget on the following link: The code snippet being used is shown below import urllib import os web = urllib.urlopen(url) html = web.read() ...

Center-align columns that are fewer in number than can fit in a row

Just starting out with Bootstrap My HTML structure looks like this: <div class="row"> <div class="col-lg-3"> First Column </div> <div class="col-lg-3"> Second Column </div> </div> Currently, there are ...

Is there a way to execute a Python script when submitting an HTML form?

I have created an HTML form and my goal is to utilize Python to transfer the data from this form into an SQLite database file. Currently, I am attempting to achieve this using CGI. I don't require anything extravagant. Below is the code that I am work ...

Counting words with JavaScript without using an input tag is a useful skill

Is there a way to count the words in a text using only p and span tags, without using input tags? How can this be achieved? <span class="word" id="word">Words Number</span> <p class="any" id="any"> ...

CSS reinitialization for the HTML5 button element

Is there a way to reset the HTML5 button tag so that it behaves consistently across all browsers? Currently experiencing issues with IE9 going haywire when trying to style the button tag. I am aware of using display:block; but what other solutions exist.. ...

I am attempting to change a "+" symbol to a "-" symbol using a Bootstrap toggle feature

Click on the text to reveal more information that drops down below. I am using Bootstrap icons and attempting to show a "+" icon when the toggle is collapsed, and a "-" icon when it's open. I've been trying to use display properties, but haven&ap ...

Introducing a pause in the function while rendering objects

After inserting setInterval into the code, it is causing all lasers to be delayed by one second. I am looking to have them fired in this order: - initially fire laser1 and laser2. - then take a 1-second break before firing another set of lasers, a ...

Does the zoom value in the HTML file adjust when I zoom in or out on the Google Map?

I'm uncertain if my question is sufficiently clear. Here's my dilemma: I've been utilizing the gmplot module in Python and I'm interested in adjusting the grids to be scalable based on the zoom level of the Google Map. However, being u ...

`<a> The value does not appear upon page load`

As a newcomer to development, I am currently experimenting and creating a sample dashboard. However, I am facing an issue where the sidebar value does not display upon loading the page. I have to manually click on a list in my sidebar for it to appear. Th ...

Stop the form from refreshing upon submission using an Ajax call in AngularJS

Currently, I am in the process of developing a search form that requires two inputs: Job title and Location. These keywords are used to gather data from various websites. However, upon submitting the form, the page refreshes itself. To prevent this, I have ...

Tips for managing the onloadedmetadata event

If a video file cannot be played by the browser due to format or codec issues, I want to notify the user about it. When the browser is unable to play a video (because of unsupported format or codec), the onloadedmetadata event does not occur. I have some ...

jPages fails to recognize dynamically added images using jQuery in real-time

I have a HTML and JS script that is designed to load images from PHP using AJAX and then place them into a div. Afterwards, a JavaScript function will paginate the images. Everything works perfectly fine when I hardcode the images manually. However, when I ...

Is there a way to adjust the position of ::before elements without affecting the border placement?

I'm struggling with an element that has a CSS style ::before to display an arrow-up inside a black circle. Check out the code here The issue I'm facing is that the character \25b2 isn't centered vertically within the circle. Adjustin ...

What is the best way to align text and an arrow on the same line, with the text centered and the arrow positioned on the

.down { transform: rotate(45deg); -webkit-transform: rotate(45deg); } .arrow { border: solid black; border-width: 0 3px 3px 0; display: inline-block; padding: 30px; } <p>Down arrow: <i class="arrow down"></i></p> Looking to ...

What is preventing the inner box from stretching to match the width of the outer box?

This question isn't really related to academics, it's more of a work-related inquiry that I've simplified into a basic question. I placed one div inside another expecting the inner div to inherit the width of the outer div. Initially, this ...