Rearrange the text on an image card using Bootstrap

I am trying to add text over an image in a Bootstrap card, but I am facing some challenges. Here is the code I have:

<div className ="container" id="mainContainer">
  <div className ="row mt-4">
    <div className="col-md-4">
      <div className="card" >
        <img  className="card-img-top bg-light mb-3" alt="" src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/1.png">
         </img>
         <div className="card-img-overlay">
           <span className="badge badge-dark"> 1 </span>
         </div>
         <div className="card-body">
           <h5 className="card-title"> Bulbasaur  </h5>
           <span className="badge badge-light"> poison </span>
         </div>
      </div>
  </div>
</div>

My desired outcome is shown in this image.

However, the current state looks like this https://i.sstatic.net/SmT3q.png

There are several differences between what I have and what I want, with the most crucial being the positioning of the element - I just can't seem to get it right.

Answer №1

             <div className ="row">
                <div className="col">
                  <div className="card">
                    <img  className="card-img-top bg-light mb-3" alt="" src="https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/1.png">
                     </img>
                     <div className="card-img-overlay d-flex flex-column justify-content-center" style={{ padding: '0px'}}>
                       <span className="badge badge-dark" style={{ width: '30%'}}> 1 </span>
                     </div>
                     <div className="card-body">
                       <h5 className="card-title"> Bulbasaur  </h5>
                       <span className="badge badge-light"> poison </span>
                     </div>
                  </div>
                </div>  

This content appears to be suitable with perhaps a few modifications.

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

Issue with ng2 pdf-viewer: Text becomes less visible as you zoom in

This custom implementation includes a zoom-in and zoom-out feature. When clicking on zoom in, the value of [zoom] increases by 0.25, and when clicking zoom out, the value decreases by 0.25. The PDF container div has a width of col-md-6 and a maximum heigh ...

Styling with CSS to ensure divs are displayed in two rows

Check out this example I found: https://jsfiddle.net/n3qs0wke/ .wrapper { max-width: 600px; border: 1px solid #333; } .big-div { min-width: 212px; min-height: 212px; max-width: 212px; max-height: 212px; display: inline-flex; ...

Hmm, seems like there's an issue with the touchable child - it must either be native or forward setNativeProps to

Currently enrolled in a ReactNative course on Coursera, I am facing an error in a 4-year-old course: "Touchable child must either be native or forward setNativeProps to a native component." I am unsure about this error and would greatly appreciate any hel ...

How can I manipulate the JSON property, an array of objects, within a React component?

As a newcomer to react development, I am facing an issue while trying to display a product page with its summary using JSON data containing arrays of objects. Upon attempting to use .map function, I encountered an error stating that the prop is undefined. ...

Folded Sidebar

Is there a way to create a collapsed sidebar without the main div moving to the right after opening it? I want the division to resize to fit the screen size instead. Here is an example of what I am looking for: https://www.w3schools.com/howto/tryit.asp?fil ...

Utilizing Angular's ng-repeat with varying directives for each iteration

I am trying to utilize ng-repeat within Angular to iterate through multiple <li> elements with a directive embedded. My goal is to have the first two items in the ng-repeat display differently in terms of styling and content compared to the remaining ...

Setting the minimum height to 100% does not function properly on the inner div

I created a div named "content" with the intention of it occupying the entire height of a window. To achieve this, I added the following CSS: body { min-height: 100%; height: auto !important; /* Additional properties included just in case */ ...

issues with table display in Internet Explorer 7

This div is positioned correctly in Internet Explorer 8 and Mozilla Firefox. <div style="display: table; margin: 0 auto; margin-top: 5%; padding-top: 13px;"></div> However, it falls out of place in Internet Explorer 7. I have read that displa ...

Ways to showcase floating items in a single row without using tables

I need help to align float elements in a single line without resorting to tables. As the user resizes the browser window, the elements currently break onto separate lines which is not the desired outcome. Here is the HTML code snippet I am using: <ul ...

Javascript code is not functioning properly (library missing?)

I recently upgraded my Bootply.com account in order to download a snippet that I believed would work perfectly. However, it seems like there's something missing here. Can anyone help me figure out what's wrong with the original Bootply.com snippe ...

Using a different background image in a React application

style={{ backgroundImage: "url(" + "http://production-partner-cdn.s3.eu-west-1.amazonaws.com/general-files/unique-image.jpg" + ")" }} I would like to show a different image in case the link for the original one is invalid ...

showing numerous lines in a flatlist

I'm using a FlatList to display data from a JSON file. I'm struggling to show multiple lines in the FlatList. Here's the code snippet: componentDidCatch render() { return( <View style={styles.MainContainer}> <FlatList ...

Handling the onChange event in the parent component for React MUI Autocomplete

I am aiming to initiate a custom function when the onChange event of the child component is triggered from the parent component. Specifically, in my scenario, the child component is the React MUI Autocomplete component. Referring to the example on Control ...

The picture in the carousel is being expanded beyond its original dimensions

I'm facing an issue with my carousel images being stretched. Can anyone provide assistance on how to prevent the stretching? https://i.sstatic.net/5CIB9.jpg Below is my code snippet: <div class="carousel-inner"> <div class="carousel-it ...

The div moves around as the user adjusts the window size

When the user resizes the window, the image illustrates the shifting footer[1] This pertains to the footer-row in the CSS settings. #footer-row { text-align: center; color: white; text-transform: uppercase; font-size: 9pt; position: absolu ...

Upon successfully authenticating with Firebase, the data refuses to appear in the console

I'm currently working on a React app that utilizes Firebase for authentication. Here is the code snippet: function signIn(){ firebase.auth().signInWithPopup(provider).then(function(result)=>{ console.log(result.user); setUserInfo(result.u ...

Insert a JavaScript object into the rendered HTML using the componentDidMount lifecycle method

I'm trying to incorporate a JavaScript object into the template once the component has mounted for tracking purposes. Here is how I want the object to be rendered: var tracking = { pagename: 'page name', channel: 'lp&ap ...

Phone website doesn't display properly on mobile device (CSS and HTML)

I am experiencing an issue where my website is not loading on mobile devices, but it functions properly when I adjust the size of my Chrome window on my laptop. @media screen { body{ background-image: url(background.jpg); backgroun ...

The state remains constant within the useEffect hook

I've been working on incorporating websockets using hooks and initializing it within useEffect. However, I've encountered an issue where the states always revert back to their initial values for the websocket. After some research, I discovered t ...

Using Javascript to generate a popup that appears right before the user tries to navigate away from the page

I have implemented a pop-up overlay on my website, triggered by clicking a button. However, I am looking to enhance this functionality so that when users scroll down the webpage and then move their cursor towards the top of the page (such as the navigation ...