- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我遇到了一个问题,我正在使用的所见即所得编辑器通过在父 ol
内部而不是内部创建新的 ol
来在列表中创建子项父 li
的,这让我很难理解如何让计数器将元素 3 识别为 3 而不是 4。我意识到正确的方法是嵌套 ol
到 li
中,但这个编辑器不想这样做,而且我有一些不懂 HTML 的人使用编辑器制作列表。
我试过 .articlecontainer ol ol { counter-increment: none } 认为它会跳过对嵌套 OL 的计数,但是由于我现在无法理解的原因,它将第三个 LI 计为 OL 的一部分,它是甚至不是(我想)的 child
.articlecontainer ol li {
line-height: 24px;
position: relative;
display: block;
padding: .4em .4em .4em 2em;
margin: .5em 0;
background: #f7f7f7;
color: #444;
text-decoration: none;
border-radius: .3em;
transition: all .3s ease-out;
}
.articlecontainer ol li:before {
content: counter(li);
counter-increment: li;
position: absolute;
left: -1.3em;
top: 25px;
/* was 50% */
margin-top: -1.3em;
height: 2em;
background: #F7941E;
width: 2em;
border: .3em solid #fff;
text-align: center;
font-weight: bold;
border-radius: 2em;
transition: all .3s ease-out;
line-height: 24px;
-moz-background-clip: padding;
color: white;
}
.articlecontainer ol {
counter-reset: li;
}
.articlecontainer ol li:hover {
background: #f7941e;
}
<div class="articlecontainer">
<ol>
<li>Item 1</li>
<li>Item 2</li>
<ol>
<li>Sub-item 1</li>
<li>Sub-item 2</li>
<li>Sub-item 3</li>
</ol>
<li>Item 3</li>
</ol>
</div>
最佳答案
你可以做的是利用 child combinator ( >
) 以确保您的选择器仅针对所需元素的直接子元素。在您的情况下,您希望应用两个子组合器;一个确保ol
元素是 .articlecontainer
的直接子元素, 另一个确保 li
元素是那些 ol
的直接子元素元素:
.articlecontainer > ol > li {
line-height: 24px;
position: relative;
display: block;
padding: .4em .4em .4em 2em;
margin: .5em 0;
background: #f7f7f7;
color: #444;
text-decoration: none;
border-radius: .3em;
transition: all .3s ease-out;
}
.articlecontainer > ol > li:before {
content: counter(li);
counter-increment: li;
position: absolute;
left: -1.3em;
top: 25px; /* was 50% */
margin-top: -1.3em;
height: 2em;
background: #F7941E;
width: 2em;
border: .3em solid #fff;
text-align: center;
font-weight: bold;
border-radius: 2em;
transition: all .3s ease-out;
line-height: 24px;
-moz-background-clip: padding;
color: white;
}
.articlecontainer > ol {
counter-reset: li;
}
.articlecontainer > ol > li:hover {
background: #f7941e;
}
<div class="articlecontainer">
<ol>
<li>Item 1</li>
<li>Item 2</li>
<ol>
<li>Sub-item 1</li>
<li>Sub-item 2</li>
<li>Sub-item 3</li>
</ol>
<li>Item 3</li>
</ol>
</div>
至于您对标记重组的评论,请注意 <ol>
元素 only allows <li>
元素作为直接子元素。如果您想拥有子菜单,它们必须位于父级<li>
内元素(如 ol > li > ol > li
)以形成有效标记。
希望对您有所帮助! :)
关于html - CSS 计数器 : Skip OL nested inside of another OL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47167122/
我正在做一个项目,我需要一个 skip-gram 模型的预训练向量。我听说还有一个名为 skip-n-gram 模型的变体可以提供更好的结果。 我想知道自己训练模型需要什么?因为我只需要它们来为我的模
我正在尝试实现 EF 提供的分页功能。我以为我只需要将简单的 Skip() 和 Take() 添加到我的查询中,但后来我收到了这条消息: Error 4 'System.Linq.IOrderedQu
到目前为止,我有一个语法一直在使用标准的 boost::spirit::ascii::space/boost::spirit::ascii::space_type 船长。 我有一些使用船长的规则和一些
我正在处理动态数据。 创建动态模型并在global.asax中注册后,如 DefaultModel.RegisterContext(typeof(masterEntities1),new Contex
在 Visual Studio 2013 Update 1 中使用 Entity Framework 6.0.2 和 .NET 4.5.1 DbContext连接到 SQL Server: 我有一个很
我正在创建一个支持动态数据的 ASP.NET 网站。当我从头开始(从 VS 中的模板)创建动态网站时,一切正常。但是,当我尝试添加动态实体 (.edmx) 文件并运行应用程序时,出现以下错误: “Sk
我们可以跳过一个可选参数并为跳过的参数赋值吗? 例如我有一个函数: public function Dialog(message:String,title:String="Note",dialogsi
我创建了一个函数来从我的 firestore 集合中提取一个随机文档,然后返回一个 FIRQuery。得到它后,我创建了一个模型文件来解析我的 firestore 文档中的任何 FIRQuery 数据
我对编程比较陌生,我想尝试看看如何在 Visual Studio 2019 中制作基本的 Windows 桌面应用程序。由于我为按钮添加了代码,所以 C2360 和 C2361 错误不断弹出,但我没有
我正在使用 Data Skipping Indexes clickhouse 中的功能,我对它的用法感到困惑。如果我在创建表时添加数据跳过索引,如下所示: CREATE TABLE MyTable (
我不确定Maven指令-Dmaven.test.skip.exec和-Dmaven.test.skip=true -DskipTests之间的区别是什么。两者似乎都抑制了测试周期。 最佳答案 “mav
假设我有一些神奇的分页黑盒类,它使用 pageIndex 和 pageSize 检索数据,如下所示: public class PaginatedList { // ... // Ch
我计划使用 Bowerjs 来管理前端依赖项,并使用 gulp.js 来连接、缩小和编译前端代码。因此,我想跳过 Rails Assets 管道,包括 sprocket。我运行以下命令来跳过 Asse
我计划使用 Bowerjs 来管理前端依赖项,并使用 gulp.js 来连接、缩小和编译前端代码。因此,我想跳过 Rails Assets 管道,包括 sprocket。我运行以下命令来跳过 Asse
我正在索引页上的 MVC 中进行分页......在这一行我得到了错误 return View( employee.ToPagedList(Page ?? 1,3)); 这里是索引方法 public
我正在搜索关于跳过连接的科学工作。 每个人都在谈论通过网络改进梯度流,这感觉很有意义。但是我很想理解和阅读归根结底的数学和代码意味着什么以及如何在 tensorflow 中深入实现它。 resnet
添加 skip规则不符合我的期望。这是由逗号和空格分隔的一对标记的语法。我制作了一个版本,其中逗号标记为 skip ,还有一个不是: grammar Commas; COMMA: '
将Jupyter用于幻灯片时,是否有默认方法将幻灯片类型设置为跳过新单元格的? 最佳答案 我针对您所要求的解决方法。 创建一个空的“跳过”幻灯片并键入: 退出 C 伏特 伏特 伏特 复制并粘贴许多空的
我正在尝试使用更新 svn update --username myusername https://my.svn.address 但是,我只是收到一条“已跳过”消息? 最佳答案 我猜你遇到了这种类型
Flash 的 MovieClip 时间轴的创建方式可以跳过帧以保持动画平滑度和音频同步。 我的问题是,如果帧上有 ActionScript,是否有可能跳过该帧,从而不调用脚本? 或者有脚本的帧永远不
我是一名优秀的程序员,十分优秀!