【问题标题】:Trying to get HTML image and text on same line试图在同一行上获取 HTML 图像和文本
【发布时间】:2017-05-28 01:56:38
【问题描述】:

我试图建立一个带有图像和文字的网站。我尝试使用内联块;排队;堵塞;漂浮;在大量的组合中,它们都不起作用。我想要左边的文字和右边的图像。

#maintext {
  margin-left: 160px;
  width: 650px;
  font-family: Tahoma, Geneva, sans-serif;
}
<div id="maintext">
        <br/>
        <br/>
		<p>
Sample text<br/>
Sample text<br/>
Sample text<br/>
Sample text<br/>
Sample text<br/>
</p>		
		</div>
		<img src="www.example.com/image" alt="Picture of something" style="width:200px;height:200px;">

【问题讨论】:

  • 您到底想达到什么目的?你要先上图吗?或者文字
  • 如果您没有可用的原型,请提供更好的描述和某种说明!
  • 旁注,它是&lt;br /&gt;&lt;br&gt;,但不是&lt;/br&gt;
  • 我要先发文字

标签: html css image text


【解决方案1】:

你想要这个吗?

#maintext img{
    float: left;
}
#maintext p {
    display: block;
}
<div id="maintext">
		<p>
text will take multiple lines.
ddddddddddddddddddddddddddddddddd
dddddddddddddddddddddddddddddddd
ddddddddddddddddddddddddddddddddd
</p>		
		</div>
		<img src="www.example.com/image" alt="Picture of something" style="width:200px;height:200px;">

如果不说我,你想让文字和图片在同一行吗?

【讨论】:

    【解决方案2】:

    您希望文本占用多行吗?
    然后这样做

        <p>
    text will take multiple lines.<br>
    ddddddddddddddddddddddddddddddddd<br>
    dddddddddddddddddddddddddddddddd<br>
    ddddddddddddddddddddddddddddddddd
    </p>
    

    &lt;br&gt; 添加到行尾

    【讨论】:

    • 不,我只是在示例代码上打错字了。我只是不知道如何在同一行获取文本和图像!
    猜你喜欢
    • 1970-01-01
    • 2014-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-15
    • 2020-08-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多