将水平制表符转换为垂直(仅限HTML&CSS;无js) [英] convert horizontal tabs to vertical (HTML & CSS only, no js)

查看:127
本文介绍了将水平制表符转换为垂直(仅限HTML&CSS;无js)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试创建一个基本门户,其左侧(而不是顶部)显示标签。理想情况下,我想完成这个没有任何javascript; HTML5& CSS3。

I'm trying to create a basic portal with tabs on the left, rather than on top. Ideally, I would like to accomplish this without any javascript; with HTML5 & CSS3 only.

我一直在使用水平制表符的以下代码: http://jsfiddle.net/Juggler/9Ue9j/2/

I've been playing with the following code for horizontal tabs: http://jsfiddle.net/Juggler/9Ue9j/2/

<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>

* {
  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-transform:rotate(-90deg);但是没能捕获到正确的元素。希望有人可以帮助我指出正确的方向。

I was trying -webkit-transform:rotate(-90deg); but have not been able to capture the correct element. Hoping someone can help point me in the right direction.

推荐答案

工作DEMO

调整 / code>& 标签

* {
  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;
    }

这篇关于将水平制表符转换为垂直(仅限HTML&CSS;无js)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆