html - 如何将文字环绕在图像周围?

标签 html css image

我有一张图片,我希望其中的一些文字环绕。我通过给出负的最高值并使其位置相对来将图像放置得更高一些。但它在图像下方显示了一些空白。我想删除带有文本的空白。我怎样才能做到这一点?

这是html代码

.what_text_container>p {}

.what_text_container>p>span {
  font-style: italic
}

.what_text_container>img {
  border-radius: 15px;
  float: right;
  position: relative;
  top: -150px;
}
<div class="what_text_container">
  <img src="assets/images/carolina.png" width="324" height="215" alt="" />
  <p>
    <span>"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful.</span>
    <br> "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder
    of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves
    or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical
    exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"<br>
    <br> "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder
    of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves
    or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example,<br>
    <br> "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder
    of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves
    or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical
    exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?"

  </p>
</div>

最佳答案

删除顶部属性。

像这样保持你的CSS。

.what_text_container > p {

}

.what_text_container > p > span {
    font-style:italic
}

.what_text_container > img {
  border-radius: 15px;
  float: right;
  position: relative;
}

或删除位置:

.what_text_container > p {

}

.what_text_container > p > span {
    font-style:italic
}



.what_text_container > img {
  border-radius: 15px;
  float: right;
  margin-top: -150px;
}

关于html - 如何将文字环绕在图像周围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26570602/

相关文章:

html - 在用户提交的数据中不转义 & 符号是否存在安全风险?

javascript - 可拖动列表到 html5 表格中存在错误

jquery - 用jquery添加类

css - 为什么 Bootstrap 3 列宽不准确?

python - 使用CoLab在Google云端硬盘上OpenCV读取和写入速度太慢

html - 图像在 chrome 和 mozilla 中不同

javascript - 增加 slider.js 箭头按钮的大小

javascript - 提交后清空textarea的内容

javascript - 选择时更改颜色 > 选项更改

android - Android中的Volley框架适合上传图片和视频吗?