简体   繁体   English

使锚点和段落都与图像内联

[英]Having both an anchor and paragraph inline with an image

Here's what I have so far: http://jsfiddle.net/hLbyy/4/ using margin property. 这是我到目前为止的内容: http : //jsfiddle.net/hLbyy/4/使用margin属性。

I have looked at various page sources (such as Wordpress where the user's avatar is inline with their details, yet this appears to be within a paragraph rather than a list item.) but I was unable to find the line of CSS that achieved this. 我查看了各种页面源(例如Wordpress ,其中用户的头像与他们的详细信息内联,但这似乎是在一个段落中而不是一个列表项中。)但是我找不到实现这一点的CSS行。

Any help towards achieving this is much appreciated. 任何帮助实现这一目标的方法都将受到赞赏。

Is this what you're looking for: 这是您要找的东西吗?

p {
    display: inline-block;
}
img {
    vertical-align: top;
}

Use " float: left; " style for img tag. 对img标签使用“ float: left; ”样式。

Somehow like THIS . 不知怎的,喜欢

The best approach for what you want to do is to wrap the link with the image in a div, then style this div as: 要做的最好的方法是将链接与图像包装在div中,然后将此div设置为以下样式:

display: block;

And wrap your link and text in another div which should align automatically at the right of your image, if you want to get fancier, you can wrap both divs in a div. 并将您的链接和文本包装在另一个div中,该div应该会自动在图片的右侧对齐,如果您想使用更漂亮的方法,可以将两个div都包装在div中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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