简体   繁体   中英

CSS: Align text to an element with display inline-block

I have a short text next to which I have to put a link. The link should not be visible as a text but as an image. So far no problems, however to use the image I have to set display:inline-block to be able to set the width/height of the tag. As soon as I do it, the next which was next to from the right jumps downwards in the containing div. I am absolutely unable to move it upwards. The code is:

<div>
    <p id="pid">Some prefixing text that shouldn't be at the bottom of the div but rather in the middle <a href="#" target="_blank">This is some link</a></p>
</div>

#pid {
    border: 1px solid blue;
    float: right;
}
#pid a {
    display: inline-block;
    width: 50px;
    height: 53px;
}

http://jsfiddle.net/DxVQr/1/

So how could I move the prefix text upwards? Thanks a lot!

是否在<a>标记上的vertical-align: middle <a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM