子弹和浮动图像之间的空间

时间:2015-12-04 15:28:53

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

我在IE11中遇到了一个问题,如果在浮动图像旁边有一个项目符号列表,那么子弹就会停留在左侧,而文本正在环绕(正如预期的那样)右侧。



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>
&#13;
&#13;
&#13;

我设法通过拉出li内的子弹来解决问题,但现在,我想将子弹与p标签对齐(也就是尊重图像&#39; s余量)。这就是我到目前为止所做的:

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

ul {
  list-style-position: inside;
  padding: 0;
}
li {
  text-indent: -1em;
  padding-left: 1em;
}
&#13;
<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>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

这会有用吗? (将overflow: hidden添加到<li>

&#13;
&#13;
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;
}
&#13;
<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>
&#13;
&#13;
&#13;