首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >将水平选项卡转换为垂直选项卡(仅HTML和CSS,没有js)

将水平选项卡转换为垂直选项卡(仅HTML和CSS,没有js)
EN

Stack Overflow用户
提问于 2013-09-30 14:06:53
回答 1查看 8.2K关注 0票数 5

我正在尝试创建一个基本的门户,其选项卡位于左边,而不是顶部。理想情况下,我希望在没有任何javascript的情况下完成这一任务;只使用HTML5和CSS3。

我一直在使用以下水平选项卡的代码:http://jsfiddle.net/Juggler/9Ue9j/2/

代码语言:javascript
运行
复制
<div id="page-wrap">
    <div class="tabs">
        <div class="tab">
            <input type="radio" id="tab-1" name="tab-group-1" checked>
            <label for="tab-1">Tab One</label>
            <div class="content">
                <p>Stuff for Tab One</p>
            </div> 
        </div>
        <div class="tab">
            <input type="radio" id="tab-2" name="tab-group-1">
            <label for="tab-2">Tab Two</label>
            <div class="content">
                <p>Stuff for Tab Two</p>
            </div> 
        </div>
        <div class="tab">
            <input type="radio" id="tab-3" name="tab-group-1">
            <label for="tab-3">Tab Three</label>
            <div class="content">
                <p>Stuff for Tab Three</p>
            </div> 
        </div>
    </div>
</div>

代码语言:javascript
运行
复制
* {
  margin: 0;
  padding: 0;
}
body {
    background: #999;  
}
#page-wrap {
  width: 1024px; 
  height: 768px;
}
    .tabs {
      position: relative;   
      min-height: 200px; /* This part sucks */
      clear: both;
      margin: 25px 0;      
    }
    .tab {
      float: left;      
    }
    .tab label {
      background: #eee; 
      padding: 10px; 
      border: 1px solid #ccc; 
      margin-left: -1px; 
      position: relative;
      left: 1px;             
    }
    .tab [type=radio] {
      display: none;   
    }
    .content {
      position: absolute;
      top: 28px;
      left: 0;
      background: white;
      right: 0;
      bottom: 0;
      padding: 20px;
      border: 1px solid #ccc;       
    }
    [type=radio]:checked ~ label {
      background: white;
      border-bottom: 1px solid white;
      z-index: 2;
    }
    [type=radio]:checked ~ label ~ .content {
      z-index: 1;
    }

我正在尝试-webkit-转换:旋转(-90 the );但是没有能够捕获正确的元素。希望有人能帮我找到正确的方向。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-30 14:38:11

Working DEMO

调整了一些用于contentlabel的CSS

代码语言:javascript
运行
复制
* {
  margin: 0;
  padding: 0;
}
body {
    background: #999;  
}
#page-wrap {
  width: 1024px; 
  height: 768px;
}
    .tabs {
      position: relative;   
      min-height: 200px; /* This part sucks */
      clear: both;
      margin: 25px 0;      
    }
    .tab {
      /*float: left; */     
       height: 41px; 
    }
    .tab label {
      background: #eee; 
      padding: 10px; 
      border: 1px solid #ccc; 
      margin-left: -1px; 
      position: relative;
      left: 1px;        
      width: 70px;
      display: block;
    }
    .tab [type=radio] {
      display: none;   
    }
    .content {
      position: absolute;
      top: 0px;
      left: 92px;
      background: white;
      right: 0;
      bottom: 0;
      padding: 20px;
      border: 1px solid #ccc;       
    }
    [type=radio]:checked ~ label {
      background: white;
      border-bottom: 1px solid white;
      z-index: 2;
    }
    [type=radio]:checked ~ label ~ .content {
      z-index: 1;
    }
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19096310

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档