【发布时间】:2015-09-01 15:41:13
【问题描述】:
大家好!我在我的 html 页面中添加了选项卡,用于在另一个模型对象中显示一个模型对象。
我的代码:
.tabordion {
display: block;
position: relative;
}
.tabordion input[name="sections"] {
left: -9999px;
position: absolute;
top: -9999px;
}
.tabordion section {
display: block;
}
.tabordion section label {
border-bottom: 1px solid #696969;
cursor: pointer;
display: block;
padding: 15px 20px;
position: relative;
width: 221px;
z-index: 100;
}
.tabordion section article {
display: none;
left: 230px;
min-width: 300px;
padding: 0 0 0 21px;
position: absolute;
top: 0;
}
.tabordion section article:after {
bottom: 0;
content: "";
display: block;
left: -229px;
position: absolute;
top: 0;
width: 220px;
z-index: 1;
}
.tabordion input[name="sections"]:checked + label {
font-weight: bold;
}
.tabordion input[name="sections"]:checked ~ article {
display: block;
}
<div class="tabordion">
<h4>Contents</h4>
{% for subject in subjects %}
{% if subject.book|safe == book.name|safe and subject.author|safe == user.username|safe %}
<section id="section{{ subject.id }}">
<input type="radio" name="sections" id="option{{ subject.id }}" checked>
<label for="option{{ subject.id }}">{{ subject.name }}</label>
<article>
{{ subject.content }}
</article>
</section>
{% endif %}
{% endfor %}
</div>
顺便说一句,我正在制作 django 项目。
问题是最后一个部分首先签入列表。这是垂直标签,我需要检查列表中的第一部分。我的代码有什么问题?
这是生成的代码:
<div class="tabordion">
<section id="section1">
<input type="radio" name="sections" id="option1" checked="">
<label for="option1">New album</label>
<article>
Content
</article>
</section>
<section id="section2">
<input type="radio" name="sections" id="option2" checked="">
<label for="option2">Name</label>
<article>
Content
</article>
</section>
</div>
【问题讨论】:
-
你能发布生成的 HTML 吗?
-
我在发布的代码中没有看到任何
li或ul -
哦,真的很抱歉,忘记了更改的代码。无论如何,它不是 ul-tabs 重要吗?