将图像和文本放在一起

时间:2015-04-06 14:06:31

标签: html css

我已经查看了本网站上有关我的问题的一些帖子,但在使用这些解决方案时我似乎遇到了问题。

这是我的HTML:

<div align="left"><div id="imgleft"><img src="tradecurrencymain.png" /></div></div>
<p>There's two different trade types: a market order and a limit order.</p>
<p>A market order allows a trade to be excuted immediately using the current trading ratio; 16 tokens equals 1 coin and 1 coin equals 15 tokens. A limit order gives you more cotrol; you can choose how much coins/tokens you will receive. For example, you may want to trade 100 tokens for 95 coins - someone has to accept the trade though.</p>

这是我的CSS:

#imgleft {
 margin-right: 30px;
 margin-left: 30px;

如果有人可以解释如何直接将图像和文字放在一起,我们将非常感激。

2 个答案:

答案 0 :(得分:0)

您可以将text-align属性放在img标记内:

<img align="left" src="tradecurrencymain.jpg" style="margin-right:30px;margin-left:30px;" />
<p>There's two different trade types: a market order and a limit order.</p>
<p>A market order allows a trade to be excuted immediately using the current trading ratio; 16 tokens equals 1 coin and 1 coin equals 15 tokens. A limit order gives you more cotrol; you can choose how much coins/tokens you will receive. For example, you may want to trade 100 tokens for 95 coins - someone has to accept the trade though.</p>

答案 1 :(得分:0)

链接到JSFIDDLE

我将所有内容都包装在一个包装器中(wrapper)然后浮动&#39; imgleft&#39;剩下。这是代码:

HTML

<div class="imgWrap" align="left">
<div id="imgleft">
    <img src="https://t2.ftcdn.net/jpg/00/31/93/43/400_F_31934352_QzlwTKN58UqGWtVEaSBvgOPqvfYxrIb7.jpg" />
</div>
<p>There's two different trade types: a market order and a limit order.</p>
<p>A market order allows a trade to be excuted immediately using the current trading ratio; 16 tokens equals 1 coin and 1 coin equals 15 tokens. A limit order gives you more cotrol; you can choose how much coins/tokens you will receive. For example, you may want to trade 100 tokens for 95 coins - someone has to accept the trade though.</p>

CSS

#imgleft {
float: left;
margin-right: 30px;
margin-left: 30px;
}