Hi there and thanks for your help. I have a div (180px to 75px) in which I need to place 3 paragraphes and an image. Now I need to place those elements in all of the divs corners. It should look something like this -> (I'm not allowed to post pictures yet. I hope you'll understand it anyway.)
This is what the div should look like (every color is an element), but I can't seem to get the description to the right.
http://i.imgur.com/bE87euS.png
But no matter how I play around with the "display: inline-block" or the "float" I can't get it to work.
I hope someon of you can give me the answer?
<div style="width:180px; height: 75px; background-color: green;" id="achievement">
<div>
<p style="display: inline-block; margin: 0px" id="title">Title Title Title</p>
<p style="margin:0px; float:right;" id="exp">500 exp</p>
</div>
<div>
<img style="padding-left: 10px;" id="img"width="50" height="50" src="image.png"/>
<p style="float:right; margin: 0px;" id="desc">Bla Bla Bla this is a description</p>
</div>
</div>
(I use an extern css file of course. I just used the style tag to make it easier for you to understand.)
Use position:relative
on the parent container to establish a positioning context. Then use position:absolute
on all the children to put them in the appropriate corners.
#parent {
position:relative;
border:3px solid blue;
height:300px;
width:500px;
padding:0;
}
p {
position:absolute;
border:2px solid;
margin:0;
padding:5px;
}
p:nth-child(1) {
border-color:green;
top:0;
left:0;
}
p:nth-child(2) {
border-color:red;
top:0;
right:0;
}
p:nth-child(3) {
border-color:yellow;
bottom:0;
left:0;
}
p:nth-child(4) {
border-color:pink;
bottom:0;
right:0;
}
<div id="parent">
<p>First</p>
<p>Second</p>
<p>Third</p>
<p>Fourth</p>
</div>
Sample implementation here
Use the text-align:right
That did the trick for me anyway.
http://jsfiddle.net/Neaw7/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With