Alignment of css html text

-4

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

example below:

    
asked by anonymous 01.01.2016 / 22:29

1 answer

1

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

Create a div with class="pictureContainer" and assign it the following style:

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

Within this 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 within this div I created a p :

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

It is totally 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>
    
02.01.2016 / 01:39