Position div inside a image (responsive)
css, html, responsive-design, twitter-bootstrap
Solution
Wrap the image and the caption in a div with `position: relative` like in this Fiddle
html
<div id="container" class="col-lg-3">
<div class="img-container">
<div class="positioning">
Some Text
</div>
<img src="http://placehold.it/300x200/eeeeee" />
</div>
</div>
CSS
.col-lg-3{
width: 25%;
min-width: 230px;
float: left;
position: relative;
min-height: 1px;
padding-left: 15px;
padding-right: 15px;
background-color: #aaa;
text-align: center;
}
.col-lg-3 img {
max-width: 100%;
}
.img-container {
display: inline-block;
position: relative;
}
.positioning{
position: absolute;
right: 15px;
bottom: 22px;
background-color: red;
color: white;
padding: 4px;
font-size: 17px;
line-height: 18px;
}
Problem
I have a problem (obviously). I have to position a element to be always on the right side of a image. But I can't use the img-Tag as a container. Also I'm using bootstrap, which makes it impossible to set a fixed width for the container. Small example jsFiddle ``` <div id="container" class="col-lg-3"> <div class="positioning"> Some Text </div> <img src="http://placehold.it/300x200/eeeeee" /> </div> ``` I hope that is understandable EDIT: Basically I want the image to behave like a container, without using "background-image"