css - 当将图像放在 <p> 的中间时,将文本环绕在图像周围

标签 css word-wrap

将 img 放在 <p> 的中间时, 文本不能环绕 img。 代码:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <style type="text/css">
        *{
            margin:0;
            padding:0;}
        div{
            width:500px;

        }
        p{
            font-size: 30px;
            word-break:break-all;
            display: inline;

        }
        span{
            font-size: 50px;
            color:yellow;
        }
        img{
            width: 30px;
            height: 80px;
            display: inline-block;
            float: right;
        }
    </style>
</head>
<body>
<div>

    <span>Fro</span>
    <p>Frontend FrontendFrontendFrontend FrontendFronFrontendFrontendFrontend FrontendFronFrontendFrontendFrontend FrontendFronFrontendFrontendFrontend FrontendFronFrontendFrontendFrontend<img src="" alt="img">FrontendFronFrontendFrontendFrontend FrontendFronFrontendFrontendFrontend FrontendFronFrontendFrontendFrontend FrontendFronFrontendFrontendFrontend FrontendFronFrontendFrontendFrontend FrontendFronFrontendFrontendFrontend FrontendFronFrontendFrontendFrontend FrontendFronFrontendFrontendFrontend FrontendFronFrontendFrontendFrontend FrontendFron/p>

</div>

</body>
</html>

它看起来像this .

那么如何让文字环绕在 img 的左侧??? 谢谢!

最佳答案

(已编辑)

只需删除 display: inline-block来自你的 img规则并删除 display:inline;来自 p标签(都没有意义): .

img {
  width: 30px;
  height: 80px;
  float: right;
}
p {
   font-size: 30px;
   word-break:break-all;
}

http://codepen.io/anon/pen/XKjpqM

关于css - 当将图像放在 <p> 的中间时,将文本环绕在图像周围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37900838/

相关文章:

html - 这个网页上的 "heart"是如何用 html/css/或其他什么完成的?

css - 修复 Zurb Foundation 3 中的列宽?

jquery - 在 JQuery 中设置选择选项的背景颜色

javascript - 未捕获的类型错误 : Cannot read property 'querySelector' of null when using with html

html - 使用 inline 可以达到相同的结果吗?

Java Swing g.drawString 自动换行

WPF TextBlock Textwrapping 导致文本被剪切

word-wrap - 硬包和软包的区别?

html - 文本不换行在表格布局中,溢出

html - 如何在 CSS 中禁用断字?