Put the SVG at the lower right corner of the image using Bootstrap

I'm currently attempting to insert an SVG into the lower right corner of an image within a bootstrap card. I experimented with a solution similar to this one: picture on the bottom right cornor of image, but when I apply CSS styles for the icon, my SVG vanishes completely. The full SVG I want to use can be found at this link:

With the current code, the cards are displayed like this:

https://i.sstatic.net/mUOtf.png I envision having the SVG positioned in the bottom right corner of the all-green image, as shown in the second picture.

.image{
  height:100%;
  position:relative;
  background-color:green;
  background-size: cover;
  background-image: url(https://communityloaves.org/wp-content/uploads/2021/05/Avatar-2-450x450.jpg);
}

.image .icon {
  position:absolute;
  bottom:0px;
  right:0px;
}

p.dash-intro.nav-btns {
    padding-top: 3rem;
}
   .col-md-4.padding-1 {
      padding-left: 5px;
      padding-right: 5px;
   }
   .ann-text {
   margin-bottom: 0px !important;
   }
   .ann-img {
   max-height: 40rem;
   }
   .dash-intro {
   color: black;
   font-size: 18px;
   margin-top: 35px;
   }
   .member-img {
   max-height: 7rem;
   margin-bottom: 6px;
   padding-left: 15px;
   }
   p.card-text {
   font-size: 11px;
   padding: 9px 15px 9px 0px;
   }
   .special {
   color: black;
   font-size: 19px;
   font-weight: bold;
   }
   .card-header {
   padding: 0.75rem 1.25rem;
   margin-bottom: 0;
   background-color: #D4E1D4;
   border-bottom: 1px solid rgba(0,0,0,0.125);
   }
   .hide {
   display: none;
   }
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a2c0cdcdd6d1d6d0c3d2e2968c928c92">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container-fluid">
   <br>
   <hr>
   <div class="row mt-3">
      <div class="col-md-12">
         <h4 class="font-weight-bold mb-3" id="members">Hub Members</h4>
      </div>
   </div>
   <div class="row">
      <div class="col-md-4 padding-1">
         <div class="card border-success mb-5">
            <div class="row g-2">
               <div class="col-md-5 col-12 text-center padding-0">
                  <div class="image">
                     <div class="icon"><svg goes here. I didnt inlcude the full svg because it was too long> </div>
                  </div>
               </div>
               <div class="col-md-7 col-12 padding-0">
                  <p class="card-text">
                     <span class="font-weight-bold">Jane D <br></span> 
                     <span class="font-weight-bold">Member Since: </span> Apr  13, 2022 <br>
                     <span class="font-weight-bold">First Donation: </span> Feb  27, 2022 <br>
                     <span class="email-text"><span class="font-weight-bold"><i class="fa fa-envelope"></i></span>  <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3e545f505b5a515b7e59535f5752105d5153">[email protected]</a></span>
                     <br><span class="font-weight-bold"><i class="fa fa-phone"></i></span>  555 555 555 (cell)                     <br><span class="font-weight-bold">Loaves to date:  </span>  5                  
                  </p>
               </div>
            </div>
         </div>
      </div>
      
     <!-- other card divs go here -->

   </div>
</div>

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

Answer №1

Adding an image to the .icon class allows you to include your own SVG.

To achieve this, you need to apply a position:relative to the parent class (which is .icon) and a position:absolute to the SVG (child), then manipulate its position using properties like bottom, left, right, and top as needed.

In this example, the CSS code includes:

bottom:0;
right: 0;

Your customized code snippet

*,
*::before,
*::after {
  box-sizing: border-box;
}

.image{
  height:100%;
  position:relative;
  background-color:green;
  background-size: cover;
}

.image .icon {
  position:relative;
  width: 100%;
  height: 100%;
}

.image .icon img{
  position: absolute;
  bottom:0;
  right: 0;
  border-radius: 100%;
  width: 80px;
}
/* Other styles included in the code */
<link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6f0d00001b1c1b1d0e1f2f5b415f415f">[email protected]</a>/dist/css/bootstrap.min.css"
      integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
      crossorigin="anonymous"
    />

<div class="container-fluid">
      <br />
      <hr />
      <div class="row mt-3">
        <div class="col-md-12">
          <h4 class="font-weight-bold mb-3" id="members">Hub Members</h4>
        </div>
      </div>
      <div class="row">
        <div class="col-md-4 padding-1">
          <div class="card border-success mb-5">
            <div class="row g-2">
              <div class="col-md-5 col-12 text-center padding-0">
                <div class="image">
                  <div class="icon">
                    <img
                      src="https://source.unsplash.com/random/100x100"
                      alt=""
                    />
                  </div>
                </div>
              </div>
              <div class="col-md-7 col-12 padding-0">
                <p class="card-text">
                  <span class="font-weight-bold">Jane D <br /></span>
                  <span class="font-weight-bold">Member Since: </span> Apr 13,
                  2022 <br />
                  <span class="font-weight-bold">First Donation: </span> Feb 27,
                  2022 <br />
                  <span class="email-text"
                    ><span class="font-weight-bold"
                      ><i class="fa fa-envelope"></i
                    ></span>
                    <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84eee5eae1e0ebe1c4e3e9e5ede8aae7ebe9">[email protected]</a></span
                  >
                  <br /><span class="font-weight-bold"
                    ><i class="fa fa-phone"></i
                  ></span>
                  555 555 555 (cell) <br /><span class="font-weight-bold"
                    >Loaves to date:
                  </span>
                  5
                </p>
              </div>
            </div>
          </div>
        </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

What is the best way to align icons in the center alongside text or paragraphs using react?

I'm struggling with centering my icons like <GrTools size="30px"/> next to my text. It's causing some alignment issues with my styled components. Here is my JavaScript: <div id='paragraph' className="container"> ...

Attempting to retrieve currentScript is causing a typeError to be thrown

I'm attempting to access a custom attribute that I added to my script tag: <script type="text/javascript" src="https://.../mysource.js" customdata="some_value"></script> To make this work on Internet Explorer ...

Utilizing jQuery to dynamically load CSS files on a webpage

For my website, I have implemented 4 different .css files to handle various screen resolutions. Here is the innovative jquery code I've developed to dynamically load these files based on the width of the screen. <link id="size-stylesheet" rel="st ...

PHP unable to display HTML form element using its designated ID attribute

I've been experiencing some difficulties with PHP echoing a label element that contains an ID attribute within an HTML form. My intention was to utilize the ID attribute in order to avoid having to modify the JS code to use the name attribute instead. ...

CSS button pressed

I came across a helpful discussion on the topic of CSS for pressed buttons, which provided some answers that I found useful. The link to the discussion can be found here: Pressed <button> CSS. Currently, I have a button within a link and I would lik ...

Creating a Toggle Function for the Hamburger Menu in JavaScript

Struggling to create a responsive navbar with a hamburger menu toggle. Followed an online tutorial and managed to get everything working, except for the toggle functionality of the menu. Clicking on the icon does nothing. Being new to this, I'm not su ...

Does text-underline qualify as a property in CSS?

My stylesheet includes a property called text-underline:none, and I'm wondering if it is a valid CSS property. Can you confirm this? ...

Arrange list items in alignment without the need for additional CSS (bootstrap) styling

<div class="card-body p-0"> <ul class="list-group list-group-flush"> <li class="list-group-item d-flex justify-content-between" th:each="extraConfig : ${extraConfigsPage.content}"> ...

What is the best way to make the text align with the top of its designated space?

I've been experimenting with different CSS properties like vertical-align, line-height, and more. This example should give you an idea of my goal. I added a small red arrow to indicate where I intend for the text to be shifted upwards. ...

What is the reason behind Gmail altering the id attributes of certain elements?

Here we have a snippet from Gmail, showcasing the "Compose" button. Note the id, it starts as ":il" when there are no unread messages. <div id=":il" class="aic"> <div class="z0"> <div class="T-I J-J5-Ji T-I-KE L3" tabindex="0" role="button" ...

Stop the container from growing in height due to column expansion

I'm facing an issue with my Vuetify two-column layout. The left column contains media with varying aspect ratios, while the right column houses a playlist. As the playlist grows in length, it extends the container, leaving empty space below the media. ...

Incorporate fresh Google sites into different web pages using iFrame integration

Wishing you a fantastic day! I am currently working on embedding a brand new Google site into another webpage. I attempted to use an iframe for this purpose, but unfortunately it did not work as expected. Here is the code snippet: <iframe width="1280 ...

Having trouble displaying a dynamically created table using jQuery

I'm a newcomer to jQuery and I need help with querying 2 web services. The goal is to query the first service, use an attribute value to query the second one, and then populate a table with data from both services. Please take a look at my code on th ...

Retrieve image details and display them in the console when the page is resized

Query: How can I retrieve and monitor the src, width, and height of all images on a webpage and display this information in the console whenever the page's size changes? Sample Code Snippet: var images = document.getElementsByTagName('img' ...

Troubleshooting padding problem in mobile gallery view with Bootstrap

Having a problem with the gallery layout in Bootstrap. It looks great on desktop view, but on mobile, there's no space between images on the same row. On mobile, the images stack vertically without any spacing between them within a row. However, ther ...

How can we display a different navbar based on whether the user is logged in or not?

Can anyone share the most effective methods for displaying a different navbar based on whether or not a user is logged in? I have considered a few approaches: One option might involve creating two separate navbars in the HTML file and using CSS to tog ...

What could be causing the image not to appear on the React app?

I'm currently working on a react website, and I'm facing an issue with the image display on the single product page. Despite trying to tweak both the react and CSS code, I haven't been able to resolve the problem. Below is my react file: im ...

What is the best way to achieve a sophisticated layout using the flex grid in CSS3?

Looking to achieve a responsive layout using flex without the need for media queries. Can anyone provide the CSS code for a layout using flex or grid? I've attempted the following: .parent { display: flex; flex-wrap: wrap; height: 100vh; } ...

Locate elements using Class with Simple Selenium

I'm facing a challenge filling out a phone number on a web portal using Selenium with VBA. Despite the element being loaded, Selenium seems to be unable to locate the text box. This is my code: Dim ch As Selenium.ChromeDriver Sub FillPhoneNumbers() ...

Guide to designing a Bootstrap footer that appears only at the bottom of the page and not at the top

I am facing a challenge with my website where some pages have a lot of elements causing scrolling, while others have only a few elements without scrolling. My goal is to have a footer that stays at the bottom of the page regardless of the page size. The f ...