【问题标题】:Aligning images alongside headers using CSS rather than HTML使用 CSS 而不是 HTML 将图像与标题对齐
【发布时间】:2018-03-07 21:11:32
【问题描述】:

我想知道一种使用 css 将图像(使用浮动或对齐)对齐到我网站上标题文本右侧的方法。我们有很多标题,它们下面只有一段左右的文本,并且由于标题当前想要占据自己的行,因此很难以美观的方式在文本中插入图像。

很遗憾,我无法让 jsbin 链接正常工作,否则我会在 OP 中提供它。

到目前为止,我发现的唯一方法是将标题样式更改为内联,但这会产生很多其他问题。我想知道是否可以通过 CSS 为所有图像更改此设置,而不是在每个实例中摆弄 html。

我附上了下面问题的截图。

谢谢。

<p class="intro">The Broadland Rivers Catchment is relatively large at around 3,200km² and is mostly rural &#8211; over 80% is arable farmland. It includes around two thirds of Norfolk and part of north Suffolk. The largest settlements include the city of Norwich and the seaside towns of Great Yarmouth and Lowestoft, where major regeneration is planned.</p>

江湖

四个主要河流(和子流域)是......

Image depicting h text not aligning to side of image

【问题讨论】:

标签: html css


【解决方案1】:

你可以这样做:

.img{
  float:right;
  height:100px;
  width:100px;
  background-color:#888;
}
<div class="img">image placeholder</div>
<p class="intro">The Broadland Rivers Catchment is relatively large at around 3,200km² and is mostly rural &#8211; over 80% is arable farmland. It includes around two thirds of Norfolk and part of north Suffolk. The largest settlements include the city of Norwich and the seaside towns of Great Yarmouth and Lowestoft, where major regeneration is planned.</p>

【讨论】:

    猜你喜欢
    • 2015-03-22
    • 1970-01-01
    • 2020-11-05
    • 2014-02-05
    • 2017-08-04
    • 1970-01-01
    • 2014-06-04
    • 2011-07-10
    • 1970-01-01
    相关资源
    最近更新 更多