Reputation: 4130
When I try to have my "vertical rule" to the right of the image, the image sticks to the bottom of the container.
<div>
<div style="display:inline-block; width:210px;">
<img src="res/img/PlayBtn.png" style="top:-100px; padding:5px;">
</div>
<div style="display:inline-block; width:12px;">
<div style="height:450px; width:0px; border:1px solid #000; margin:5px; margin-top:0px;"></div>
</div>
</div>
How can I achieve this, while keeping the image at the top?
Upvotes: 0
Views: 78
Reputation: 6051
I recommend using floats to put things side-by-side, but for a quick solution, just add vertical-align:top
to the button div:
...
<div style="display:inline-block; width:210px; vertical-align: top;">
<img src="res/img/PlayBtn.png" style="top:-100px; padding:5px;">
</div>
...
Upvotes: 0
Reputation: 12923
the default positioning for inline-block
elements is baseline
. Set: vertical-align:top
on your divs
<div>
<div style="display:inline-block;vertical-align:top; width:210px;">
<img src="res/img/PlayBtn.png" style="top:-100px; padding:5px;">
</div>
<div style="display:inline-block;vertical-align:top; width:12px;">
<div style="height:450px; width:0px; border:1px solid #000; margin:5px; margin-top:0px;"></div>
</div>
</div>
Upvotes: 1