gpt4 book ai didi

html - 元素符号和 float 图像之间的空间

转载 作者:太空宇宙 更新时间:2023-11-04 11:04:28 25 4
gpt4 key购买 nike

我在 IE11 中遇到一个问题,如果元素符号列表位于 float 图像旁边,则元素符号会停留在左侧,而文本则环绕(如预期)在右侧。

div {
padding: 20px;
}
img {
float: left;
margin-right: 20px;
}
<div>
<img src="http://placebear.com/300/300" />
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<ul>
<li>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</li>
<li>The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using</li>
<li>'Content here, content here', making it look like readable English.</li>
<li>Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy.</li>
<li>Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</li>
</ul>
</div>

我设法通过将元素符号拉入 li 来解决问题,但现在,我想将元素符号与 p 标签对齐(也就是尊重图像的利润)。这是我目前所拥有的:

div {
padding: 20px;
}
img {
float: left;
margin-right: 20px;
}

ul {
list-style-position: inside;
padding: 0;
}
li {
text-indent: -1em;
padding-left: 1em;
}
<div>
<img src="http://placebear.com/300/300" />
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<ul>
<li>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</li>
<li>The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using</li>
<li>'Content here, content here', making it look like readable English.</li>
<li>Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy.</li>
<li>Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</li>
<li>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</li>
<li>The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using</li>
<li>'Content here, content here', making it look like readable English.</li>
<li>Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy.</li>
<li>Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</li>
</ul><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>

最佳答案

这行得通吗? (将 overflow: hidden 添加到 <li> )

div {
padding: 20px;
}
img {
float: left;
margin-right: 20px;
}

ul {
list-style-position: inside;
padding: 0;
}
li {
text-indent: -1em;
padding-left: 1em;
overflow: hidden;
}
<div>
<img src="http://placebear.com/300/300" />
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<ul>
<li>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</li>
<li>The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using</li>
<li>'Content here, content here', making it look like readable English.</li>
<li>Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy.</li>
<li>Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</li>
<li>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.</li>
<li>The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using</li>
<li>'Content here, content here', making it look like readable English.</li>
<li>Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy.</li>
<li>Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</li>
</ul><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>

关于html - 元素符号和 float 图像之间的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34091752/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com