将文本对齐图像右侧&&文本不会环绕图像

JoJ*_*JoJ 11 css image

应该是这样的:

[img] text text
      text text
Run Code Online (Sandbox Code Playgroud)

这是如何完成的?

看起来很直接,但我很挣扎.

Jas*_*aro 7

您可以使用 display:inline-block;

img{
    display:inline-block;
    width:75px;
    height:100px;
    border:1px solid red;
    vertical-align:top;
    margin-right:10px;
}

div{
    display:inline-block;
    width:200px;
}
Run Code Online (Sandbox Code Playgroud)

示例:http://jsfiddle.net/jasongennaro/SK9ad/

inline-block;使用IE7,请将以下内容添加到每个规则:

zoom: 1;
*display:inline;
Run Code Online (Sandbox Code Playgroud)


Pau*_*aul 2

既然您知道图像的尺寸:

HTML:

<div style="position: relative;">
    <img id="theimg" ... />
    <div id="besidetheimg">
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

#theimg{
    position: absolute;
    top: 50%;
    margin-top: -50px; // Half the width of the image
    width: 100px;
    height: 100px;
}

#besidetheimg{
    margin-left: 100px; // width of image
}
Run Code Online (Sandbox Code Playgroud)

这是一种有点奇怪的方法。我不确定是否有更好的方法,并且它有效: http: //jsfiddle.net/dvLqC/