adrianmanuel adrianmanuel - 4 months ago 6x
Javascript Question

Text div over image resizable

I wonder if there is any way to put text inside a div over an image, i know can use z-index, but I need the text gets smaller as the size of the image. thanks for everything i want to resizable the textbox with the image


Here is one way, using viewport units vw

div {
  position: relative;
  width: 30vw;
  height: 30vw;
div img {
  display: inline-block;
  width: 100%;
  height: 100%;
div span {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 6vw;
  color: red;
  font-weight: bold;
  <img src="" alt="">
  <span>Hey there</span>