简体   繁体   English

内联IMG拆分P标签

[英]Inline IMG splitting P tag

I have an image which I want to be inline with text. 我有一张要与文字对齐的图像。 I can't work out how to do this whilst maintaining the formatting and not having the paragraph split as seen in the fiddle... 我无法弄清楚如何做到这一点,同时又要保持格式设置,并且不要像小提琴一样分割段落。

<style>
    .test1 img, .test1 p, .test1 h1, .test1 h2, .test1 h3{
        display:inline;
        vertical-align:top;
    }
    img{
        width:150px;
        height:150px;
    }
</style>
<div class="test1" align="left">
    <img src="">
    <h2>eLearning</h2>
    <h3>No one said work had to be boring.</h3>
    <p>text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text </p>
</div>

https://jsfiddle.net/nxyLv9vm/2/ https://jsfiddle.net/nxyLv9vm/2/

The first section in the fiddle displays my problem and the second section shows how the formatting of the text should look next to the image as well. 小提琴的第一部分显示了我的问题,第二部分显示了文本格式在图像旁边的外观。

For The Record 作为记录

I can get this to work by encapsulating the p,h2,h3 tags in a div and making this inline, however I want the text to flow full width directly under the image. 可以通过将p,h2,h3标签封装在div中并使其内联来使其工作,但是我希望文本在图像的正下方完全流动。

Are you looking for something like this? 您是否正在寻找这样的东西?

https://jsfiddle.net/kumiau/u98x2ttg/ https://jsfiddle.net/kumiau/u98x2ttg/

I removed the inline css formating and floated the image to the left. 我删除了内联CSS格式,并将图像浮动到左侧。

img{
  width:150px;
  height:150px;
  float: left;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM