Bootstrap: The card-image-overlay has extended beyond the boundaries of the image

Apologies for this question, but CSS is not my thing. I just can't wrap my head around it.

I'm attempting to superimpose some text and a button on an image, but the result is that they overflow from the image;

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

This snippet contains the entire card code;

<div class="col-md-6 col-lg-4 mb-4">
  <div class="card listing-preview">
    <h4 class="text-primary">{{ listing.title }}</h4>
    <div>
      <img class="card-img-top" src="{{ listing.map_url }}" alt="">
      <div class="card-img-overlay">
        <h2>
          <span class="badge badge-secondary text-white">£{{ listing.price|floatformat }}</span>
        </h2>
      </div>
    </div>
    <div class="card-body">
      <div class="listing-heading text-center">
        <p>
          <i class="fas fa-map-marker text-secondary"></i> {{ listing.city }} {{ listing.state }}, {{ listing.zipcode }}</p>
      </div>
      <hr>
      <div class="row py-2 text-secondary">
        <div class="col-6">
          Bills Inc: &nbsp {% if listing.bills_inc %}
          <i class="fas fa-check"></i> {% else %}
          <i class="fas fa-times"></i> {% endif %}
        </div>
        <div class="col-6">
          Deposit: {% if listing.deposit %} £{{ listing.deposit|floatformat }} {% else %}
          <i class="fas fa-times"></i> {% endif %}
        </div>
      </div>
      <div class="row py-2 text-secondary">
        <div class="col-6">
          <i class="fas fa-bed"></i> Type: {{ listing.type|title }}</div>
        <div class="col-6">
          <i class="fas fa-bath"></i> Bathrooms: {{ listing.bathrooms }}</div>
      </div>
      <hr>
      <div class="row py-2 text-secondary">
        <div class="col-12">
          <i class="fas fa-user"></i> by {{ listing.advertiser_type }} {{ listing.advertiser_name|title }}</div>
      </div>
      <div class="row text-secondary pb-2">
        <div class="col-6">
          <i class="fas fa-clock"></i> {{ listing.list_date | timesince }}</div>
      </div>
      <hr>
      <a href="{% url 'listing' listing.id %}" class="btn btn-primary btn-block">More Info</a>
    </div>
  </div>
</div>

If you could also overlay 'London, N20' at the bottom of the map, you'll earn bonus points (upvote).

Thank you in advance.

Answer №1

If you want one element to display above another, you can use the z-index property:

#top-layer {
    width: 80px;
    height: 80px;
    background-color: blue;
    position: absolute;
    z-index: 3;
}

#bottom-layer {
    width: 60px;
    height: 60px;
    background-color: yellow;
    position: absolute;
    left: 20px;
    top: 20px;
}
<div id="top-layer"></div>
<div id="bottom-layer"></div>

The element with the higher z-index value will be displayed on top of elements with lower values.

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

Highlighting the current menu item by comparing the URL and ID

Looking to make my navigation menu items active based on URL and ID, rather than href. None of the suggested solutions (like this one, this one, or this one) have worked for me. This is how my Navigation is designed: <nav id="PageNavigation"& ...

An unsolicited border encompassing an image that does not resemble a CSS border or outline within the realm of Bootstrap 4

Utilizing Bootstrap4 Cards with .PNG image sources has resulted in an unexpected border appearing. It's not a border or outline issue. https://i.sstatic.net/KHgnP.png Here is the HTML <div class="row"> <div class="col-md-3"> <d ...

Toggle the visibility of a div by clicking on another div in a

I have created a unique design where a div features a background image of a face, along with a paragraph, two buttons, and an input box inside it. While I know this question has been asked before, my scenario is slightly different. I want the div with the ...

Can we pause and resume the progress bar using Javascript in conjunction with animationPlayState?

Looking for a way to control a progress bar script that runs for 180 seconds and then redirects the browser? Check out the code snippet below. I've added an onclick event to test pausing the progress bar. My goal is to pause, reset, and adjust the dur ...

Utilizing Jquery to automatically scroll to a specific div on page load by setting an

I am attempting to automatically scroll to the div specified in the URL. The URL may include one of 21 different IDs such as: url.com/test#lite1 url.com/test#lite2 url.com/test#lite3 This scrolling action should happen when the page loads (so that user ...

Changing the element to "position: absolute" prevents it from stretching to the full width

After styling my login page to perfection with the container div set to display: block and position: static, I encountered an issue when attempting to switch to display: inline-block or position: absolute. The container div stopped adhering to its maximum ...

What is the process for creating Bootstrap styles with Sass?

After obtaining the npm bootstrap package, I navigated to node_modules/bootstrap/dist/css/bootstrap.css and inspected the styles for .alert-danger: .alert-danger { color: #721c24; background-color: #f8d7da; border-color: #f5c6cb; } Despite searching ...

What is the best way to implement an Android-style tab bar using Bootstrap for web pages?

Can you provide guidance on using Bootstrap to create an Android tab bar similar to the one seen in the WhatsApp application for web pages? Thank you for your assistance. ...

Popover disappears when scrolling the page, but its position remains constant in Angular 4+

After clicking on an icon, a popover appears. I've noticed that the popover has a delay set, but when I scroll, the popover also moves along with it. Is there a way to keep the popover in place and not have it affected by scrolling? <md-badge cla ...

Is it possible to create a resizable menu without distorting its appearance?

After setting up a menu on my website, I noticed that when resizing the window, it spills over into other divs on the same line. Despite trying multiple solutions, I have been unsuccessful in resolving this issue. The navigation for the menu is contained w ...

The subscription data for nested classes appears to be displaying as undefined

In my current project, I am utilizing Angular 8 and facing an issue with a nested class. The problem arises when trying to access data from an observable subscribe operation in the child class (Players) within the main Tournament class. Until the data is r ...

Creating an HTML file using PUG in a local environment (using npm and gulp)

Is there a way to automatically generate an HTML file with the same name as my Pug file whenever I save using gulp? I've checked all the documentation on but it only explains how to return Pug content in console... ...

Firefox not recognizing height attribute in table cells

My dilemma revolves around the fact that my table cells are not displaying at the designated height. Here is the code snippet I am working with: <html> <head> </head> <body> <table style="border: 1px solid black; border-radiu ...

What steps can I take to ensure the browser only shows the page once it has completely loaded?

I find it frustrating when webpages load slowly and you can see the process happening. In my opinion, it would be more satisfying to wait until everything is fully loaded - scripts, images, and all - before displaying the page. This brings up two questio ...

``How can I apply styling to a child component in React within a regular HTML element?

I'm currently learning React and faced a unique situation while working on projects. Here's the scenario - I have two React child components nested under a standard HTML element. If I need to target and style each individual React child element ...

Customize the appearance of each TreeItem in JavaFX using CSS to assign unique

I am looking for a way to color individual Tree Items in a treeView based on specific conditions. I found a promising answer, but unfortunately, I am struggling to implement it. You can check out the answer here. My main obstacle is understanding how to u ...

Is it possible to dynamically assign and call functions through an Object in Angular 6?

I implemented a click handler for a button that is generated dynamically. Within the click handler function, I am invoking a callback function. However, I encountered an issue where an error message popped up stating that "Callback function is not a fu ...

Angular dynamically changes the placeholder text in an input based on a selection made in a mat select dropdown

Trying to change the placeholder text in a mat-input based on selection in mat-select, but struggling to bind it to the selected option. <mat-form-field appearance="outline" class="search-field" style="width:40vw"> ...

Adding a JavaScript global variable into a <div> element within the HTML body

Here is an example HTML tag: <div data-dojo-type="dojox.data.XmlStore" data-dojo-props="url:'http://135.250.70.162:8081/eqmWS/services/eq/Equipment/All/6204/2', label:'text'" data-dojo-id="bookStore3"></div> In ...

CSS3 :target and display:none inconsistency problem in Internet Explorer and Firefox

Creating a one-page site with navigation tabs that toggle between hidden divs using :target CSS3 selector is my current project. To ensure the first div is visible upon page load, I implemented this line of code: document.location.href = "#div1"; The HTM ...