【发布时间】:2016-10-22 00:04:49
【问题描述】:
我的问题
所以我正在尝试为我的网站创建一个新闻部分。每个部分都包含标题、图像和文章本身。问题是文章文本将拒绝放在图片旁边,除非我自己使用<br> 将其拆分。
说明
每个部分的所有元素都列在一个 div 元素下。该部分包括标题、图像和文章。之后,图片有了自己的类,文章也到了CSS之后。
- 标题是块元素
- 图片是一个内嵌块元素
- 文章是一个内嵌块元素
HTML 代码(从不包括导航栏及以上的新闻框开始)
<div id=newsboard>
<div class=newsboard_topic>
<h1>Website in Development!</h1>
<img src="/image/newsboard/construction.gif" alt="Dev">
<p class=newsboard_topic_article>
Greetings!
<br>The GeoVillage website is currently under construction, but feel free to register and login to check out the stuff we have so far!
<br>- Geo Jones
<br>Owner and Developer
</p>
</div>
<div class=newsboard_topic>
<h1>kimmy and donald!</h1>
<img class=newsboard_topic_picture src="/image/newsboard/kimdon.jpg" alt="kimmyanddonald">
<p class=newsboard_topic_article>
The fan fiction of Donald Trump and Kim Jong Un! Yes, they photoshopepd it. This is a test by the way to test the standing of articles.
</p>
</div>
</div>
HTML 部分的 CSS 代码
#newsboard {
margin-left: 100px;
margin-right: 100px;
margin-top: 25px;
margin-bottom: 25px;
border-color: #0099FF;
border-style: solid;
border-width: 5px;
}
.newsboard_topic {
padding: 20px;
display: block;
}
.newsboard_topic_article {
display: inline-block;
vertical-align: top;
word-wrap: break-word;
margin: 0px;
padding: 10px;
}
.newsboard_topic_picture {
display: inline-block;
}
活生生的例子 目前在geo-village.com上
【问题讨论】: