简体   繁体   English

通过有序列表CSS / HTML中的数字敲击

[英]Striking through a number in an ordered list CSS/HTML

I have an HTML ordered list, that I need to apply a strikethrough to. 我有一个HTML有序列表,我需要应用删除线。 I have done this in CSS as below: 我在CSS中做了这个,如下所示:

.Lower-Alpha {
  list-style: lower-alpha;
  margin-top: 2pt;
  margin-bottom: 2pt;
  text-decoration: line-through;
}

The issue I am having is that this strikes through the content in the list, but not the number of the list (and I need to do both). 我遇到的问题是,这会打击列表中的内容,而不是列表的数量(我需要同时执行这两项操作)。

Eg I am getting: a. 我得到了:a。 struckthrough content 突破内容

but I need: a. 但我需要: a。 struckthrough content 突破内容

Any suggestions welcome. 欢迎任何建议。 Cheers 干杯

easy as pie: list-style-position: inside; 像馅饼一样简单: list-style-position: inside;

http://jsfiddle.net/seler/NWbrR/ http://jsfiddle.net/seler/NWbrR/

edit: it looks like it's browser dependent behaviour. 编辑:它看起来像是依赖于浏览器的行为。 in mozilla it renders ok. 在mozilla它呈现好。

edit2: for full browser compability u can use this js script: http://jsfiddle.net/seler/32ECB/ edit2:为了完整的浏览器兼容性你可以使用这个js脚本: http//jsfiddle.net/seler/32ECB/

@Haem; @Haem; You can apply :after property 您可以申请:after财产:after

li:after{
    border-top:1px solid red;
    display:block;
    content:"";
    margin-top:-8px;
}

check the fiddle for more may be that's help you 检查小提琴更多可能是帮助你

http://jsfiddle.net/sandeep/NWbrR/4/ http://jsfiddle.net/sandeep/NWbrR/4/

列表样式不是这样的样式 - 你必须删除li里面的列表样式标识符(a,b,c等)作为内容。

This is default browser behaviour and you wont be able to strike through the number/letter provided by the list. 这是默认的浏览器行为,您无法浏览列表提供的数字/字母。 If it is possible in your situation you could hide the numbering provided by the list and add it to the list text content yourself. 如果在您的情况下可以隐藏列表提供的编号并将其自己添加到列表文本内容中。

You might have to take care of the numbering yourself - either manually, server-side, or some jQuery - and use an unordered list like this: 您可能必须自己处理编号 - 手动,服务器端或某些jQuery - 并使用这样的无序列表:

<style>
.Lower-Alpha
{
  margin-top: 2pt;
  margin-bottom: 2pt;
  text-decoration: line-through;
  list-style: none;
}
</style>

<ul>
   <li class="Lower-Alpha">a. Foo</li>
   <li class="Lower-Alpha">b. Bar</li>
</ul>

This'll render as: 这将呈现为:

a. 一个。 Foo

b. Bar 酒吧

It can be done as follows: 它可以如下完成:

  1. Create a wrapper <div> around the <ul> . <ul>周围创建一个包装器<div> <ul>

  2. Style the wrapper <div> with the strikethru (or whatever other font size/style you're wanting for the list item numbers) 使用strikethru(或者您希望列表项目编号的任何其他字体大小/样式)设置包装器<div>的样式

  3. Style the <li> elements back to your normal font settings. <li>元素设置回常规字体设置。

The list item numbers will then pick up the font settings from the parent <div> , and will have the strike-thru, and the list content will be normal text. 然后,列表项编号将从父<div>获取字体设置,并具有删除线,列表内容将是普通文本。

Note, this will only work if you want all your list item numbers styled the same way. 请注意,只有当您希望所有列表项目编号的样式相同时,才能使用此选项。 Your question implies that this is what you want, but if you only wanted to do strike-thru on specific list items then you'd need to use @seler's solution. 你的问题意味着这就是你想要的,但如果你只想对特定的列表项进行攻击,那么你需要使用@ seler的解决方案。

You can't style the list item. 您无法设置列表项的样式。 It might look better this way? 它可能看起来更好吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM