Html css text alignment

Asked

Viewed 111 times

-4

How to adapt a text over a photo, where it will start at the bottom of the photo or div and rise as the size?

example below:inserir a descrição da imagem aqui

  • 1

    You could explain better what you want, got a little vague...

  • the example in the photo is perfect friend

  • I need it to look like photo 3

  • You could post your code?

1 answer

1


As the question had no details, I created a model from the image:

I believed a div with the class="pictureContainer" and assigns it the following style:

.pictureContainer{
  width: 400px; 
  height: auto; !important
  position: relative; !important
}

Inside that div I created an image with a width: 100%. And I created a div with a class="pictureText", with this style:

.pictureContainer .pictureText{
  width: 100%;
  height: 40%;
  background: rgba(0, 0, 0, 0.5);
  position: absolute; !important
  bottom: 0; !important
}

And inside that div I created a p:

.pictureContainer .pictureText p{
  padding: 10px;
  position: absolute; !important
  bottom: 0; !important
  color: #fff;
}

It is fully responsive and proportional, just change the width of div.pictureContainer and the rest will suit.

Complete code

*{
  margin: 0;
  padding: 0;
}
.pictureContainer{
  width: 400px;
  height: auto;
  position: relative;
}
.pictureContainer img{
  width: 100%;
}
.pictureContainer .pictureText{
  width: 100%;
  height: 40%;
  background: rgba(0, 0, 0, 0.5);
  position: absolute;
  bottom: 0;
}
.pictureContainer .pictureText p{
  padding: 10px;
  position: absolute;
  bottom: 0;
  color: #fff;
}
<div class="pictureContainer" >
  <img src="http://www.novosaplicativos.com.br/wp-content/uploads/2015/11/anonymous-isis-bitcoin-opisis.jpg" alt="">
  <div class="pictureText" >
  <p>Hacker descobre evidências de que os EUA teriam espaçonave de guerra.</p>
  </div>
</div>

  • That’s right. Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.