Reputation: 15434
Here is fiddle https://jsfiddle.net/qyLjxwrv/1/.
As you can see left and right titles are aligned to screen corners, while I would like to align them to image corners. Trying it for 2hours without a success...
.wrapper {
position: absolute;
left: 0px;
right: 0px;
top: 0px;
background-color: rgba(213,213,213,.5);
text-align: center;
}
.info {
text-align: left;
}
.right-title {
float: right;
}
<div class="wrapper">
<div class="inner">
<div class="info">
<span class="left-title">Left</span>
<span class="right-title">Right</span>
</div>
<img src="http://i.imgur.com/CRcoPPS.jpg" />
</div>
</div>
Note that I don't want titles to appear inside image, but above it and aligned with left and right corner of image.
Upvotes: 1
Views: 45
Reputation: 78686
It seems that you can do it like this simply, and see the comments inline.
.wrapper {
display: table; /*shrink-to-fit*/
margin: 0 auto; /*center*/
}
.wrapper img {
max-width: 100%; /*responsive*/
}
.left-title {
float: left; /*left*/
}
.right-title {
float: right; /*right*/
}
<div class="wrapper">
<div class="inner">
<div class="info">
<span class="left-title">Left</span>
<span class="right-title">Right</span>
</div>
<img src="http://i.imgur.com/CRcoPPS.jpg" />
</div>
</div>
Edit: Demos with the gray background color partly and full page.
Upvotes: 2