I am trying to position an info box over an image but still have both stay inside the container

Joeman

I have tried things like using position absolute on one and position relative on the other but it always messes up one so that it overflows even though i have set overflow to hidden. This is my code so far.(ignore the fact that it says className and not class)

<div className="card">
      <div className="img">
        <img src={props.image} alt="" />
      </div>
      <div className="infoContainer">
        <h2>{props.title}</h2>
        <h3>{props.description}</h3>
      </div>
    </div>

that is the jsx

.card {
  display: flex;
  width: 400px;
  height: 500px;
  background-color: blue;
  border-radius: 20px;
  margin-left: 20px;
  overflow: hidden;
}
.infoContainer {
  display: flex;
  flex-direction: column;
  width: 100%;
  background-color: aqua;
  align-self: flex-end;
  align-items: center;
  justify-content: center;
  padding: 10px;
}
.img {
}

anyone have any ideas? Any help is much appreciated. This is the output of what i have so far im not sure what to do. Im trying to get the image to be where the dark blue is. The dark blue is where im trying to get the image to show up

Jon P

Set position:relative on the card. That way any contained elements with postion:absolute will be positioned relative to the card element

.card {
  width: 400px;
  height: 500px;
  background-color: blue;
  border-radius: 20px;
  margin-left: 20px;
  overflow: hidden;
  /*By settign this to relative, absolutely positioned
   descendant elements will be positioned relative to this
  */
  position: relative;
}

.infoContainer {
  display: flex;
  flex-direction: column;
  width: 100%;
  align-self: flex-end;
  align-items: center;
  justify-content: center;
  padding: 10px;
  /*Position the infoContainer*/
  position: absolute;
  /*Set it to the bottom*/
  bottom: 0;
  /*Bring it to the front*/
  z-index: 10;
  background-color: rgba(255, 255, 255, 0.8);
}

.img {}
<div class="card">
  <div class="img">
    <img src=https://www.fillmurray.com/400/500 alt="" />
  </div>
  <div class="infoContainer">
    <h2>Bill Murray</h2>
    <h3>Star of the classic film Garfield</h3>
    <!--<h2>{props.title}</h2>
    <h3>{props.description}</h3>-->
  </div>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

I need text to stay inside a container without using the <br> tag over and over

Position text box over image

I need to position image at the bottom of the background image and have them stay in place when window is resized

Trouble trying to position Image on Container

If I have struct inside another struct and I am trying to have them inside an array

I am using javaFx and i am trying to determine if a point is inside a bounding box

Wish to hover over a container and have both elements (an Image) and p react and change at the same time

I am trying to put this glitched image in my website, I put the CSS code and HTML in but it still does not work

I am trying to figure out how I can have my dropdown items be displayed over other content

Why doesn't the image in my footer stay inside the container?

I am trying to give "box-shadow" to my image but i doesn't works

Trying to position a CSS circle over the top of an Image

I am trying to reference a merged cell on one worksheet and have it copy over into the next sheet

I am trying to create a box in React, and it is not working

I am trying to bind a list to a combo box

I am trying to select an image from a box and then click on the aligning button using selenium python

I am new to golang, I am trying to create a zip that must have a folder inside that is: tosend.zip/archivos/file.png

I am trying http connection over android

I am trying to use a slider component in my angular project i have ran the ng add @angular/material still the following error

i am trying to send email through nodemailer, i have permitted my google account for less secure apps, still getiing error

How do I make an image shrink to fit inside a fixed position flex box modal

I am trying to combine a image view and a text view inside of a view pager. Is it possible?

make images expand on hover from center and make image still stay in box

`conda info -a` not showing the PATH I am trying to add

I am trying to add and image with PHP

onmouseout event happens when I am still hovering over the label

absolute position image inside bootstrap thumbnail container image

image does not stay in right position

See attached snapshot. I have created such circle box through container in flutter. But I am seeking for widget. Do flutter have a widget for it?