Home > Back-end >  How to I move text to the bottom of in an image overlay for card in CSS/HTML?
How to I move text to the bottom of in an image overlay for card in CSS/HTML?

Time:04-03

I've been trying to change justify-content in the CSS class to "flex-end" and "end" but the text is not moving down to the bottom.

I think we should focus on the img-overlay class, because that's where we position the text on the card.

.overlay.overlay-sm .shape {
  filter: brightness(0) invert(1);
  opacity: 0.15;
  height: 40px;
}

.overlay.overlay-sm .shape.wave {
  height: initial;
  width: 70px;
}

.overlay.overlay-sm .shape.xshape {
  height: 30px;
}

.portfolio .square {
  top: 28%;
  left: 20%;
}

.portfolio .circle {
  top: 8%;
  right: 35%;
}

.portfolio .triangle {
  top: 10%;
  right: 4%;
}

.portfolio .half-circle1 {
  bottom: 13%;
  left: 5%;
}

.portfolio .half-circle2 {
  bottom: 35%;
  left: 20%;
}

.portfolio .xshape {
  bottom: 10%;
  left: 8%;
}

.portfolio .wave {
  bottom: 38%;
  left: 6%;
}

.grid {
  width: 100%;
  margin: 1.5rem 0;
}

.grid-item {
  width: 33.33%;
  padding: 1rem 1.2rem;
  display: flex;
  justify-content: center;
}

.gallery-image {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  height: 330px;
  width: 100%;
  cursor: pointer;
  /* justify-content: flex-end; */
}

.gallery-image img {
  position: absolute;
  height: 115%;
  width: initial;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center;
  /* justify-content: flex-end; */
  /* cursor: pointer; */
}

.gallery-image .img-overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  margin: auto;
  z-index: 2;
  color: var(--light-one);
  background-color: rgba(120, 76, 251, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 2rem 3.2rem;
  /* opacity: 0; */ /* I removed this one :: Rickard */ 
}

.img-overlay .plus {
  position: relative;
  /* width: 100px; */
  /* height: 100px; */
  margin: auto 0;
}

.plus:before,
.plus:after {
  content: "";
  position: absolute;
  width: 4.5rem;
  height: 3px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--light-one);
  border-radius: 3px;
}

.plus:before {
  transform: translate(-50%, -50%) rotate(-90deg);
}

.img-description {
  width: 100%;
}

.img-overlay h3 {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 1.5rem;
}

.img-overlay h5 {
  font-size: 1.15rem;
  font-weight: 300;
}

.gallery-image:hover .img-overlay {
  opacity: 1;
  transition: 0.3s ease;
}

.gallery-image:hover img {
  transform: translate(-50%, -50%) scale(1.1);
}

.more-folio {
  display: flex;
  justify-content: center;
}
<div >
  <div >
    <img src="./img/portfolio/port1.jpg" alt="">
    <div >
      <div >
        <div >
          <h3>Logo Design</h3>
          <h5>View Demo</h5>
        </div>
      </div>
    </div>
  </div>
</div>

CodePudding user response:

Remove styles of .img-overlay .plus:

.overlay.overlay-sm .shape {
  filter: brightness(0) invert(1);
  opacity: 0.15;
  height: 40px;
}

.overlay.overlay-sm .shape.wave {
  height: initial;
  width: 70px;
}

.overlay.overlay-sm .shape.xshape {
  height: 30px;
}

.portfolio .square {
  top: 28%;
  left: 20%;
}

.portfolio .circle {
  top: 8%;
  right: 35%;
}

.portfolio .triangle {
  top: 10%;
  right: 4%;
}

.portfolio .half-circle1 {
  bottom: 13%;
  left: 5%;
}

.portfolio .half-circle2 {
  bottom: 35%;
  left: 20%;
}

.portfolio .xshape {
  bottom: 10%;
  left: 8%;
}

.portfolio .wave {
  bottom: 38%;
  left: 6%;
}

.grid {
  width: 100%;
  margin: 1.5rem 0;
}

.grid-item {
  width: 33.33%;
  padding: 1rem 1.2rem;
  display: flex;
  justify-content: center;
}

.gallery-image {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  height: 330px;
  width: 100%;
  cursor: pointer;
  /* justify-content: flex-end; */
}

.gallery-image img {
  position: absolute;
  height: 115%;
  width: initial;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center;
  /* justify-content: flex-end; */
  /* cursor: pointer; */
}

.gallery-image .img-overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  margin: auto;
  z-index: 2;
  color: var(--light-one);
  background-color: rgba(120, 76, 251, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 2rem 3.2rem;
  /* opacity: 0; */ /* I removed this one :: Rickard */ 
}

.plus:before,
.plus:after {
  content: "";
  position: absolute;
  width: 4.5rem;
  height: 3px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--light-one);
  border-radius: 3px;
}

.plus:before {
  transform: translate(-50%, -50%) rotate(-90deg);
}

.img-description {
  width: 100%;
}

.img-overlay h3 {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 1.5rem;
}

.img-overlay h5 {
  font-size: 1.15rem;
  font-weight: 300;
}

.gallery-image:hover .img-overlay {
  opacity: 1;
  transition: 0.3s ease;
}

.gallery-image:hover img {
  transform: translate(-50%, -50%) scale(1.1);
}

.more-folio {
  display: flex;
  justify-content: center;
}
<div >
  <div >
    <img src="./img/portfolio/port1.jpg" alt="">
    <div >
      <div >
        <div >
          <h3>Logo Design</h3>
          <h5>View Demo</h5>
        </div>
      </div>
    </div>
  </div>
</div>

CodePudding user response:

This would be my approach to overlay your text on an image:

.gallery-image {
  border-radius: 16px;
  min-height: 330px;
  cursor: pointer;
  background: center / cover no-repeat url("https://source.unsplash.com/random/300x200");
}

.gallery-image .img-overlay {
  display: grid;
  place-content: end center;
  min-height: inherit;
  border-radius: inherit;
  color: var(--light-one, #fff);
  background-color: rgb(120 76 251 / 0.55);
}

.img-overlay h3 {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 1.5rem;
}

.img-overlay h5 {
  font-size: 1.15rem;
  font-weight: 300;
}
<div >
  <div >
    <h3>Logo Design</h3>
    <h5>View Demo</h5>
  </div>
</div>

  • Related