使用CSS而不是HTML

时间:2018-03-07 12:02:48

标签: html css

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

我很遗憾无法让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

1 个答案:

答案 0 :(得分:0)

你可以这样做:

.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>