如何将文字远离子弹?

问题描述 投票:2回答:1

有没有让文本包裹远离子弹,就像使用list-style-position: outside但使用我的自定义伪元素子弹?

div {
  width: 250px
}

ul {
  padding: 10px;
  list-style: none;
}

ul>li::before {
  padding-right: 10px;
  position: relative;
  top: 5px;
  font-size: 2em;
  content: "\2022";
  color: #fee100;
}
<div>
  <ul>
    <li>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</li>
    <li>VLorem Ipsum is simply dummy text of the printing.</li>
  </ul>
</div>
html css html-lists listitem bulletedlist
1个回答
1
投票

您可以使用绝对位置而不是相对于负值的相对位置:

div {
  width: 250px
}

ul {
  padding: 10px;
 list-style: none;
}

ul>li {
 position:relative;
}

ul>li::before {
  padding-right: 10px;
  position: absolute;
  left:-15px;
  top:-10px;
  font-size: 2em;
  content: "\2022";
  color: #fee100;
}
<div>
  <ul>
    <li>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</li>
    <li>VLorem Ipsum is simply dummy text of the printing.</li>
  </ul>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.