html有序列表序号怎么变色,html – 如何正确标记/样式有序列表以补偿大项目编号...

我正在动态生成包含有序列表的网页.该页面包含10个项目,并使用属性“start”相应地对项目进行编号.具有’list-style-position:outside’的通用有序列表对于项目编号小于1000的项目非常适用.

当项目编号的长度为4位或更多时,问题就出现了,项目编号的一部分被容器边界部分遮挡.调整列表填充并不是一个真正的解决方案,因为对于具有比填充调整后要处理的更多位数的项目计数,它仍将中断,以及由于过度填充而使单个数字项看起来很糟糕.

使用’list-style-position:inside’解决了项目编号被遮挡的问题,但引入了一个新问题,因为这样做会导致项目内容包装在列表项目编号下,而不是对齐到数字的右侧.

我总是可以隐藏项目编号,并在每个< li>内部引入一个新的浮动div.并将内容设置为列表项目编号,但虽然这解决了我的演示文稿问题,但在语义上它不太正确,因为我纯粹出于表现的原因添加标记和内容.

对于我不知道的这种困境,有没有css解决方案?

#container {

border: solid;

}

#container div, #container h1 {

border: solid 1px blue;

}

#outsideOl {

list-style-position: outside;

}

#insideOl {

list-style-position: inside;

padding-left: 0;

}

  1. one

    the content inside the <li> is aligned to the right of the numbers, which is what I want, but long numbers are obscured by the container's border. The list elements are shifted to the right by the default padding for an <ol> element. If the list item number happens to be longer than the padding, part of the number is obscured.
  2. two
  3. three
  4. four
  5. five
  6. six
  7. seven

  1. one

    long numbers affect content flow and as such are left aligned to the container border (which is good because they are no longer obscured). The problmen now is the block content inside the li gets bumped down to the next line, and left aligns with the numbers. Curse you css!
  2. two
  3. three
  4. four
  5. five
  6. six
  7. seven
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值