试图在同一行上获取HTML图像和文本

时间:2017-01-12 20:05:49

标签: html css image text

我试图拥有一个包含图片和文字的网站。我尝试使用inline-block;排队;块;浮动;大量的组合,没有一个工作。我想要左边的文字和右边的图片。

#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;">

2 个答案:

答案 0 :(得分:0)

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

dateFormatter.locale = NSLocale.init(localeIdentifier: "fr")
let frenchDate       = dateFormatter.stringFromDate(date!) // now it is 12-Janv.-2017 

<p> text will take multiple lines.<br> ddddddddddddddddddddddddddddddddd<br> dddddddddddddddddddddddddddddddd<br> ddddddddddddddddddddddddddddddddd </p> 添加到行尾

答案 1 :(得分:0)

你想要这个吗?

#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;">

如果不说我,你想要文字和图像在同一条线上吗?