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

标签 html css internet-explorer internet-explorer-11

我在 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/

相关文章:

html - 如何更改 <a href> 颜色/删除格式

php - 难以传递 GET 变量?

c# - 使用文本框值在 HTML 中构建 URL

javascript - 为什么 jquery 移动按钮显示为迷你?

IE 中的 jQuery slideToggle 和 div

html - 如何在不同页面上使菜单项大小不同

css - 如何摆脱 WordPress 中容器之间的白线?

javascript - 检测并删除输入框溢出

javascript - 使用 <object> 标签嵌入 ActiveX 对象与使用 new ActiveXObject() 创建一个之间的区别

html - Flash Player z-index 和 Internet Explorer