html - 更改图像和侧边栏

标签 html css tabview

我正在尝试通过单击鼠标来获取下拉菜单的外观。 到目前为止我的 html 看起来有点像这样

<div id="tabs">
<ul id="tab_list">
    <li><a href="" id="tab1" class="active">Contents</a></li>
    <li><a href="" id="tab1" class="active">Contents</a></li>
    <li><a href="" id="tab1" class="active">Contents</a></li>
</ul>
</div>
<div id="tab_contents">
<div class="">
<h2>The table of contents</h2>
<p>The descriptive text for this tab</p>
</div>
<div class="hide">
<h2>About the author</h2>
</div>
<div class="hide">
<h2>About the downloads</h2>
</div>
</div>

和CSS

#tabs{margin-top: 1em;} 
#tab_list{margin: 0;
          padding: 3px 6px;
          border-bottom: 1px solid black;}            
#tab_list li {list-style-type: none;
              display: inline;}               
#tab_list li a {padding: 3px 1em;
                margin-left: 3px;
                text-decoration: none;
                font-weight: bold;
                color: black;
                background: yellow;
                border: 1px solid black;
                border-bottom: none;}                   
#tab_list li a:hover{background: white;
                    border-color: black;}                       
#tab_list li a:active{background-color: white;
                      border-bottom: 1px solid white;}                        
#tab_contents div{padding: 5px 10px 10px;
                  border: 1px solid black;
                  border-top: 0;
                  height: 100px;}                     
.hide {display: none;}

现在我想根据我选择的类别隐藏和显示每个内容页面。 我怎样才能获得这种效果?请直接在我的例子中工作。

最佳答案

如果我理解正确你想要什么,我不确定它是否可以在没有 js 的情况下完成,为什么你有相同 id 的标签?

关于html - 更改图像和侧边栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10858738/

相关文章:

ios - 如何快速将多个 View 连接到单个选项卡栏项目?

Android Tabhost,切换方向重新加载很慢

java - 在选项卡 View 中交换 View 寻呼机时增加 Recyclerview 的项目

javascript - 如何使用jquery在父级上设置点击事件?

javascript - 模拟点击js

javascript - Div 随文本水平扩展

css - 文本应该在段落中换行,但没有

javascript - 从不同页面加载时如何使选项卡处于事件状态

html - div 内并排的表格加上水平滚动

html - 如何调整换行标签?