CSS浮动图像和文本换行

CSS浮动图像和文本换行,css,css-float,Css,Css Float,我尝试将图像向左浮动,将描述环绕图像,并使用“浮动”和“清除”属性将位置浮动到左下角: 我想我已经浮动的图像和位置,并已清除这两个属性正确。然而,我似乎不能漂浮和明确的第2段。我在这里做错了什么?Float确实会改变元素的行为 您可能会考虑使用Flex框。 如果您想让图像和段落相邻并留有边距 检查以下代码段 旁白{ 显示器:flex; 边框:1px纯红; } 在img旁边{边框:2px点黄色;} 旁白p:n-child2{ 利润率:10px; 边框:2倍纯绿; } 照片贴 知识是一种美德,是

我尝试将图像向左浮动,将描述环绕图像,并使用“浮动”和“清除”属性将位置浮动到左下角:


我想我已经浮动的图像和位置,并已清除这两个属性正确。然而,我似乎不能漂浮和明确的第2段。我在这里做错了什么?

Float确实会改变元素的行为 您可能会考虑使用Flex框。 如果您想让图像和段落相邻并留有边距

检查以下代码段

旁白{ 显示器:flex; 边框:1px纯红; } 在img旁边{边框:2px点黄色;} 旁白p:n-child2{ 利润率:10px; 边框:2倍纯绿; } 照片贴

知识是一种美德,是一种美德,是一种美德,是一种美德。但是,在最低限度上,我们需要一个实验室来进行日常工作。两人或两人在一个无教区的房间里互相指责。除偶尔因疏忽而死亡外,不得因疏忽而导致动物死亡


Image

如果希望段落环绕图像,除了浮动图像外,还必须将其与段落放在同一水平面上,而不是放在其中一个段落内:。
    <aside>
        <h2>Photo Posts</h2>
        <p><a href="http://lorempixel.com/100/100/animals/" title="Image Title" target="_blank"><img src="http://lorempixel.com/200/300/animals/" alt="Image Title"></a></p>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        <p>Image</p>
    </aside>

aside img {border: 2px dotted yellow; float: left;}

aside:first-of-type p:first-of-type {border: 2px dotted blue;}
aside:first-of-type p:nth-of-type(2) {border: 2px dotted green; float: left; overflow: auto;}
aside:first-of-type p:last-child {border: 2px dotted red; float: left; clear: both; font-style: italic;}