gpt4 book ai didi

javascript - 如何在应用程序中实现选项卡功能?

转载 作者:行者123 更新时间:2023-12-01 03:37:07 25 4
gpt4 key购买 nike

我正在尝试在不使用js的情况下实现选项卡功能。我从这里得到了示例

https://ampbyexample.com/advanced/tab_panels_with_amp-selector/

当我只有两个选项卡时,我可以使用此示例。查看输出 https://jsbin.com/vixaquloki/edit?html,output

但是当我尝试制作嵌套选项卡“选项卡位于另一个选项卡内”时。。它什么也没显示。为什么?看我的代码

但是当我单击选项卡一时,它会显示选项卡内的两个内容。但是当我单击“选项卡一内”时,它会隐藏所有内容为什么?

<amp-selector role="tablist"
layout="container1"
class="ampTabContainer">
<div role="tab"
class="tabButton"
selected
option="a">Tab one</div>
<div role="tabpanel"
class="tabContent">

最佳答案

问题是所选命令发生冲突,请参阅此我刚刚从内部选项卡中删除了所选命令

    <script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-selector" src="https://cdn.ampproject.org/v0/amp-selector-0.1.js"></script>
<style amp-custom>
.ampTabContainer {
display: flex;
flex-wrap: wrap;
}

.tabButton[selected] {
outline: none;
background: #ccc;
}

.tabButton {
list-style: none;
flex-grow: 1;
text-align: center;
cursor: pointer;
}

.tabContent {
display: none;
width: 100%;
order: 1; /* must be greater than the order of the tab buttons to flex to the next line */
border: 1px solid #ccc;
}

.tabButton[selected]+.tabContent {
display: block;
}

/* For example below (not required) */
.itemCustom {
border: 1px solid #000;
height: 280px;
width: 380px;
margin: 10px;
text-align: center;
padding-top: 140px;
}
amp-selector {
padding: 1rem;
margin: 1rem;
}
</style>

<amp-selector role="tablist" layout="container1" class="ampTabContainer">
<div role="tab" class="tabButton" selected option="a">Tab one</div>
<div role="tabpanel" class="tabContent">

<div>one div
<amp-selector role="tablist" layout="container" class="ampTabContainer">
<div role="tab" class="tabButton" option="a">inside Tab one</div>
<div role="tabpanel" class="tabContent">Tab one content... </div>
<div role="tab" class="tabButton" option="b">Tab two</div>
<div role="tabpanel" class="tabContent">Tab two content... </div> </amp-selector> </div> </div>
<div role="tab"
class="tabButton"
option="b">Tab two</div>
<div role="tabpanel"
class="tabContent">Tab two content... </div>

</amp-selector>

关于javascript - 如何在应用程序中实现选项卡功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44183957/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com