I am trying to place text within image like in the snipped below but using divs, scalable layout for text and resizable text.
Like this:
h3 {
word-break: break-word; /* non standard for webkit */
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
.img{
width:640px;
height:100%;
}
.image {
position: relative;
width: auto; /* for IE 6 */
max-height: 640px;
}
h2{
background-color: rgba(0, 0, 0, 0.5);
padding-left: 20px;
padding-right: 20px;
padding-bottom: 10px;
padding-top: 10px;
position: absolute;
bottom:-15px;
left: 0;
width: 600px;
color:white;
}
<div class="image">
<img src="http://i.imgur.com/VCsr2MH.png" alt="" class="img" />
<h2 lang="en">A Movie in the Park: Kung Fu Panda</h2>
</div>
<div class="image">
<img src="http://i.imgur.com/VCsr2MH.png" alt="" class="img" />
<h2 lang="en">A Movie in the Park: Kung Fu Panda saasffdafadfadfda</h2>
</div>
<div class="image">
<img src="http://i.imgur.com/VCsr2MH.png" alt="" class="img" />
<h2 lang="en">Incomprehensibilities ffafefeafea fefeefes gregrgregregerge</h2>
</div>
Here is what i got responsive version without text and layout on top of image:
* {
box-sizing: border-box;
}
html,
body {
height: 100%;
margin: 0;
}
html {
font-family: sans-serif;
}
body {
display: flex;
align-items: center;
}
.wrapper {
overflow: hidden;
margin: auto;
}
div > div {
margin: 0.5rem;
float:left;
}
div:nth-child( 4n ){
clear: left;
}
img{
width: 256px;
max-height: 100%;
}
.note {
width: 100%;
padding: 0;
background-color: #000;
color: #eee;
text-align: center;
position: absolute;
top: 0;
left: 0;
}
@media( max-width: 1024px ){
div:nth-child( 2n + 3 ){
clear: left;
}
div:nth-child( 4n ){
clear: none;
}
.note {
background-color: rgba( 0, 0, 0, 0.6 );
}
}
<div class="note">Resize viewport to change layout</div>
<div class="wrapper">
<div><img src="http://i.imgur.com/VCsr2MH.png" alt=""/></div>
<div><img src="http://i.imgur.com/VCsr2MH.png" alt=""/></div>
<div><img src="http://i.imgur.com/VCsr2MH.png" alt=""/></div>
<div><img src="http://i.imgur.com/VCsr2MH.png" alt=""/></div>
<div><img src="http://i.imgur.com/VCsr2MH.png" alt=""/></div>
<div><img src="http://i.imgur.com/VCsr2MH.png" alt=""/></div>
</div>
Additionally there is some problem with resizing images (size) when they are not a divider of number 1024 in responsive snippet.