1

我想在 span 元素的右侧对齐图像。

我在 td 元素中可以正常工作,但是现在我已经将它移到了跨度中,它无法正常工作。将不胜感激任何建议。

<div style="width:400px;">
    <span style="display:inline-block;width:50%;" onclick="location.href='http://www.google.com'">Go to Google</span><span style="display:inline-block;width:50%;float:right;weight:bold;" onclick="location.href='http://www.yahoo.com';><img src="test.gif" width=40 height=40 border=0>Go to Yahoo</span>
</div>

http://jsfiddle.net/sVdE3/

4

1 回答 1

5

这个怎么样?

<div>
    <span onclick="location.href='http://www.google.com';">Go to Google
        <img src="https://www.google.com/images/srpr/logo11w.png" width="40" height="40" border="0" />
    </span>
    <span onclick="location.href='http://www.yahoo.com';">Go to Yahoo
        <img src="https://www.google.com/images/srpr/logo11w.png" width="40" height="40" border="0" />
    </span>
</div>

CSS 如下:

div {
    width: 400px;
}
span {
    display: inline-block;
    width: 50%;
    float: left;
}
img {
    float: right;
}

http://jsfiddle.net/grim/sVdE3/2/

请注意,您的标记中有一些错误,例如您没有关闭的引号 (")。

于 2014-01-06T03:11:32.267 回答