adrianmanuel adrianmanuel - 1 year ago 72
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

Answer Source

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>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download