上下文 :

我正在使用背景图像的跨接包装,以便可以进行项目符号点样式设置。



问题 :

如果内容太窄,则下一个span元素会加入同一行。

查看下面的图片:

html - 我正在使用的每个span元素后都需要换行-LMLPHP

如您所见,内容为“增值税率和退款”的跨度加入同一行。



我的代码:



.arrowIconFooter{
    background-image:url(../img/arrowFooter.png);
    background-position:left;
    background-repeat: no-repeat;
    padding: 6px 8px 6px 13px;
    float: left;
    font-family: monospace;
    font-size:15px;
    color:#66809E;
    font-weight:400;
}

<section class="floating-left">
  <a href="#">  <span class="arrowIconFooter">Cycle to Work Scheme Update</span></a>
  <a href="#">  <span class="arrowIconFooter">Divided Planning to Maximise Tax Credits</span></a>
  <a href="#">  <span class="arrowIconFooter">Maximum NI Contributions</span></a>
  <a href="#">  <span class="arrowIconFooter">VAT Rates and Refunds</span></a><br>
  <a href="#">  <span class="arrowIconFooter">February Question and Answer Section</span></a>
  <a href="#">  <span class="arrowIconFooter">February Key Tax Dates</span></a>
</section>





我怎样才能使下一个跨度转到下一行?

最佳答案

添加display: block并删除float,如下所示:



.arrowIconFooter {
  display: block;
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY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P50Kq8nI0MTd1zlQMvzmwwJ8ME0mteqLK2lK7seQ8uUDTLZhoAhGzIpsOJ2u2Vo+gBDJMhLkrdm+u3U4t5om2BBJLlhErgUBBEHCjHMCBIGD7IiXmUf9ksu0CLGhKj7YGm/MkPhaV1BFkWwos4hci/qAICiwcCbgeBucCavIPumfdMfgmPvni5CPZohv0RU9IElZkIxUuAbAbgGWkoOMVqI0PJAkC9mRz8+dDT582zJfrCRX1wTsaBzKq7Xy0xtdMlqPuQU4wQE8PlIV0szylQeDNxtg5BEg0HMHT6LntDMQ5MGq3VwCjFu1YBd+g0N0IkAED2YtdOrvnm/SN+cq5pMbsH9VNJgLox6lBXlu++aSRCzljq9yVia1bAMYrL05jbrmG04RlFLyUW72HIzFMTV7I9T7OqcdY66dgeRUaeZ4YeW/LN2Xa4dqrnMisHIKd+cE8GdhsDCmOjVMtadr3KZ1fdgxpAzccAf9k505DcN11wQRCE9cPYRdFMiALjf62aGwNSlfpOQkQbsOQJOt75vsyHwxXJ/LY8dKuhvsABoW9Pmxdfs3ee/qNtuGpGZenpOl5O0j9ZemeGDccZURK/d3g/6S2PqkEK+d3WPYBEsZeAsCeJGrCvfcfBO7RNRj8kgl9OVF1x0M9Ur4MYFjhEQTrujCoYAeUDJ++dvVLPd96mvikeDSi+GqlJ6RmcFZhy81iP+X/r/ijwADAISDLHeCN/xPAAAAAElFTkSuQmCC');
  background-position: left;
  background-repeat: no-repeat;
  padding: 6px 8px 6px 23px;
  font-family: monospace;
  font-size: 15px;
  color: #66809E;
  font-weight: 400;
}

<section class="floating-left">
  <a href="#">
    <span class="arrowIconFooter">Cycle to Work Scheme Update</span>
  </a>
  <a href="#">
    <span class="arrowIconFooter">Divided Planning to Maximise Tax Credits</span>
  </a>
  <a href="#">
    <span class="arrowIconFooter">Maximum NI Contributions</span>
  </a>
  <a href="#">
    <span class="arrowIconFooter">VAT Rates and Refunds</span>
  </a>
  <a href="#">
    <span class="arrowIconFooter">February Question and Answer Section</span>
  </a>
  <a href="#">
    <span class="arrowIconFooter">February Key Tax Dates</span>
  </a>
</section>

关于html - 我正在使用的每个span元素后都需要换行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35483120/

10-09 15:30