簡體   English   中英

將水平制表符轉換為垂直制表符(僅限HTML和CSS,無js)

[英]convert horizontal tabs to vertical (HTML & CSS only, no js)

我正在嘗試在左側創建一個帶有選項卡的基本門戶,而不是在頂部。 理想情況下,我想在沒有任何JavaScript的情況下完成此任務; 僅限HTML5和CSS3。

我一直在玩水平標簽的以下代碼: 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); 但是無法捕獲正確的元素。 希望有人可以幫助我指出正確的方向。

工作演示

contentlabel調整了一些CSS

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM