CSS 和将文本放置在图像旁边

标签 css image text alignment

我有一些文本和图像,我想将文本放置在图像的右侧。 我已使图像向右浮动,但问题是我只想将 2 第一行放置在图像旁边。 我希望其余文本保留在图像下方,就像关闭 float 时一样。

网址示例: http://salient.peterstavrou.com/5937-2/

我有以下图像代码:

.audiodownload {
  width: 120px !important;
  float: left;
}

我正在使用 WordPress,页面中的 HTML 是:

 <h2>Good Audiobook</span></h2>

  Click on the image below to see if the Audiobook is available.
 <a href="https://www.youtube.com/results?search_query=The+7+Habits+of+Highly+Effective+People+audiobook" target="_blank"><img class="audiodownload" src="http://www.peterstavrou.com/wp-content/uploads/2015/10/YouTube-MP3-Audio.jpg" alt="Audiobook Download" /></a>
 If the Audiobook is available then you can download it to your computer as an .mp3 audio file by following these instructions
&nbsp;

The 7 Habits of Highly Effective People is recognized as one of the most influential audiobooks ever recorded. In this Audiobook Stephen R. Covey presents a holistic, integrated, principle-centered approach for solving personal and professional problems. 
With penetrating insights and pointed anecdotes, Stephen Covey reveals a step-by-step pathway for living with fairness, integrity, honesty and human dignity - principles that give us the security to adapt to change, and the wisdom and power to take advantage of the opportunities that change creates.

最佳答案

在您想要位于图像下方的段落样式中,使用:

p {
    clear: both;
}

指定 p 元素的左侧或右侧不允许有 float 元素。来自 http://www.w3schools.com/cssref/pr_class_clear.asp

关于CSS 和将文本放置在图像旁边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33029921/

相关文章:

jquery - 使用 jQuery 切换图像

android - 在 Android 中构建时,Unity3D 文本不显示

javascript - 单击另一个后隐藏 div

html - 简单的 CSS 居中(在 div 中居中文本 + 高图像)

javascript - 在 dhtmlx 甘特图中垂直滚动时,任务行和网格行未正确对齐

python - 从 .txt 文件中删除 html 和 uuencode

list - 将文本文件转换为列表

css - Chrome 可视化问题 CSS

python - 如何使用普通 python (不是 ipython)查看或保存 <IPython.core.display.Image object>?

css - FlexSlider - 导航图像