【问题标题】:Dot leaders spanning excessive lines跨越过多线条的点领导者
【发布时间】:2018-03-01 12:03:10
【问题描述】:

我正在尝试创建一个响应式分类键,包括基于嵌套列表和用于创建目录的代码的点前导符。它几乎完成了,但是当不需要时,点领导者有时会跨越两条线。当“页码”或“物种”太长而无法与初始文本放在同一行时,它们应该只跨越第二行,迫使它进入下面的行。

我想要的一个例子可以在这里看到: 4a 是我想要的样子,4b 是不是我想要的样子

我不确定是什么原因导致这种情况发生,因为它不会一直发生。

#key {
	overflow: hidden;
}

ol {
  list-style-position: outside;
}

ol.list {
	padding-left: 25px;
 	margin-top: -21.8px;
}

.list li {
  position: relative;
  list-style-position: outside;
  list-style-type: lower-alpha;
	padding-left: 5px;
	text-indent: -10px;
}

.list .list-item {
  margin: 0 0px 15px;
}

.list .list-item:last-child {
  margin: 0 0 40px;
}

.list .list-item::before {
  content: ".......................................................................................";
  text-indent: 5px;
  letter-spacing: 6px;
  position: absolute;
  left: 0px;
  bottom: 0px;
  z-index: -10;
}

.list .list-item .text::after {
  content: "....................................................................................";
  text-indent: 5px; 
  letter-spacing: 6px;
  position: absolute;
  left: 0px;
  z-index: -10;
}

.list .list-item span {
  display: inline;
  background-color: #fff;
  padding-right: 1px;
	padding-left: 10px;
}

.list .list-item .number {
  float: right;
  font-weight: bold;
  color: #198e9d;
  background-color: #fff;
  padding-left: 11px;
}

/* Clearfix */
.list .list-item::after {
  content: "";
  display: block;
  clear: both;
}

/* --figcaption-- */
.wp-caption-text {
	float:right;
	font-size: 0.9em;	
}

/* image info */
.info {
	text-align:right;
  color:grey;
	margin-top:-1em;
	font-size:0.899em;
	background-color:#fff
}
<div id="key">
<ol>
 	<li>
<ol class="list">
 	<li class="list-item"><span class="text">Bill short, less than 15% of lower jaw – fork length (Fig. 5a);anus located well anterior of first anal fin by a distance greater than length of first anal-fin base (Fig. 6a)</span><span class="number"><em>Tetrapturus angustirostris</em> (shortbill spearfish)</span></li>
 	<li class="list-item"><span class="text">Bill moderately long, more than 18% of lower jaw – fork length (Fig. 5b); anus slightly anterior of first anal fin by a distance of less than length of first anal-fin base (Fig. 6b)</span><span class="number"><em>Kajikia audax</em> (striped marlin)</span></li>
</ol>
</li>
 	<li>
<ol class="list">
 	<li class="list-item"><span class="text">Pectoral fins curved in shape, resembling a half sickle (Fig. 7a), rigid unable to be folded back against sides of body (more flexible in individuals &lt;15 kg); dorsal-fin tip bluntly rounded (Fig. 8a); branchiostegal frill long, extending to near level with rear edge of operculum (Fig. 9a); second dorsal-fin anterior to second anal-fin (Fig. 10a)</span><span class="number"><em>Istiompax indica</em> (black marlin)</span></li>
 	<li class="list-item"><span class="text">Pectoral fins strap like (Fig. 7b) flexible, able to be folded back against sides of body; dorsal fin pointed at tip (Fig. 8b); branchiostegal frill short, extending to well forward of rear edge of operculum (Fig. 9b); second dorsal-fin posterior to second anal-fin (Fig. 10b)</span>
<span class="number"><em>Makaira nigricans</em> (blue marlin)</span></li>
</ol>
</li>
</ol>
</div>

【问题讨论】:

  • @omukiguy 这就是我最初基于我的代码的内容,它对我的​​问题没有帮助。欢呼
  • 粘贴一个JSbin,我看看。但我相信这是不可避免的。

标签: html css html-lists


【解决方案1】:

我无法复制您的问题,如果您可以粘贴示例链接。但是,使用负边距应该作为最后的手段,我相信可能会导致问题,具体取决于浏览器。试试这个。

#key {
    overflow: hidden;
}

ol {
  list-style-position: outside;
}

ol.list {
    padding-left: 25px;
    margin-bottom: 20px;
}

.list li {
  position: relative;
  list-style-position: outside;
  list-style-type: lower-alpha;
    padding-left: 5px;
    text-indent: -10px;
}

.list .list-item {
  margin: 0 0px 15px;
}

.list .list-item:last-child {
  margin: 0;
}

.list .list-item::before {
  content: ".......................................................................................";
  text-indent: 5px;
  letter-spacing: 6px;
  position: absolute;
  left: 0px;
  bottom: 0px;
  z-index: -10;
}

.list .list-item .text::after {
  content: "....................................................................................";
  text-indent: 5px; 
  letter-spacing: 6px;
  position: absolute;
  left: 0px;
  z-index: -10;
}

.list .list-item span {
  display: inline;
  background-color: #fff;
  padding-right: 1px;
    padding-left: 10px;
}

.list .list-item .number {
  float: right;
  font-weight: bold;
  color: #198e9d;
  background-color: #fff;
  padding-left: 11px;
}

/* Clearfix */
.list .list-item::after {
  content: "";
  display: block;
  clear: both;
}

/* --figcaption-- */
.wp-caption-text {
    float:right;
    font-size: 0.9em;   
}

/* image info */
.info {
    text-align:right;
  color:grey;
    margin-top:-1em;
    font-size:0.899em;
    background-color:#fff
}

【讨论】:

  • 我尝试删除 ol.list 中的负边距,但它没有改变任何东西。它只是有时会发生,因此很难重新创建。我在 Chrome 上使用 WordPress。这是你需要的吗? jsbin.com/wayarukace/1/edit?html,css,output干杯
猜你喜欢
  • 2021-05-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-30
  • 1970-01-01
  • 2010-11-13
  • 1970-01-01
  • 2021-03-17
相关资源
最近更新 更多