仅使用css的表格导航

时间:2013-06-24 18:34:09

标签: css navigation tabular

我在外部文件中有一个表格导航列表(我选择的样式)包含以下代码:

.tabs
{
    position:relative;
    text-align:left; /* This is only if you want the tab items at the center */        
    width: 90%;   
    padding: 0;
    margin: 0;
    /*border: 1px solid green;*/

}
.tabs ul.menu
{
    list-style-type:none;
    display:block; /* Change this to block or inline for non-center alignment */
    width:570px;  
    /*  min-width:570px;  
      max-width:800px;     
    vertical-align: bottom;
    /*border: 1px solid red;*/
}
.tabs ul.menu > li
{
    display:inline;
    float:center;
    vertical-align: bottom;   
   /** border: 1px solid yellow;*/  
    cursor:hand; 

}
.tabs ul.menu li > a
{
    color:#7a7883;
    text-decoration:none;
    display:inline-block;
    text-align:center;
    border:1px solid #f1f3f4;
    padding:5px 10px 5px 10px;  
    width: 25%;  

    font-size:15px;   
    font-family:"Times New Roman", Times, serif;

    border-top-left-radius:5px; -moz-border-radius-topleft:4px; -webkit-border-top-left-radius:5px;
    border-top-right-radius:5px; -moz-border-radius-topright:4px; -webkit-border-top-right-radius:5px;
    -moz-user-select:none;
    cursor:hand;    

      /* Safari 4-5, Chrome 1-9 */
  background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#aeb8c0));

  /* Safari 5.1, Chrome 10+ */
  background: -webkit-linear-gradient(top, #aeb8c0, #fff);

  /* Firefox 3.6+ */
  background: -moz-linear-gradient(top, #aeb8c0, #fff);

  /* IE 10 */
  background: -ms-linear-gradient(top, #aeb8c0, #fff);

  /* Opera 11.10+ */
  background: -o-linear-gradient(top, #aeb8c0, #fff);    
}
.tabs ul.menu li > a:hover
{

    color: #fff;   
    cursor:hand; 

}
.tabs ul.menu li > div
{
    display:none;
    position:absolute;
     width:98%;  
    /* max-width:700px;*/ 
     min-height:230px;
    left:0; 
    margin: 0 15px 0 15px;
    z-index:-1;
    text-align:left;
    padding:0;  
}
.tabs ul.menu li > div > p
{
    border:1px solid #f1f3f4;      
    background-color: #f5f9fc;  
    width: 99%;
    padding:10px;
    margin:0;  
    color: #65636e;
    font-size:12px;   
    font-family:"Times New Roman", Times, serif;
    text-decoration: none;       
    min-height:200px;

}
.tabs ul.menu li > a:focus
{  
    color: #f5f9fc;  

}

.tabs ul.menu li:target > a
{
    cursor:default;
         /* Safari 4-5, Chrome 1-9 */
  background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f1f3f4), to(#fff));

  /* Safari 5.1, Chrome 10+ */
  background: -webkit-linear-gradient(top, #fff, #f1f3f4);

  /* Firefox 3.6+ */
  background: -moz-linear-gradient(top, #fff, #f1f3f4);

  /* IE 10 */
  background: -ms-linear-gradient(top, #fff, #f1f3f4);

  /* Opera 11.10+ */
  background: -o-linear-gradient(top, #fff, #f1f3f4);   
    cursor:hand; 
}

.tabs ul.menu li:target > div
{
    display:block;
}

在网页上我有这个:

<!-- Side NAVIGATION -->
<!-- Wrapper 2-Content -->
  <div class="wrapper" style="min-height: 200px;"">
    <!-- content -->
    <div class="content">
    <div class="tabs">
    <ul class="menu">
    <li id="item-1">
        <a href="#item-1">Bla Bla 1</a>
        <div><p>Tab Content 1</p></div>
    </li>
    <li id="item-2">
        <a href="#item-2">Bla Bla 2</a>
        <div><p>Tab Content 2</p></div>
    </li>
    <li id="item-3">
        <a href="#item-3">Bla Bla 3</a>
        <div><p>Tab Content 3</p></div>
    </li>            
    </ul>

</div>  
    </div> 
    <!-- content -->
<!-- end of Side NAVIGATION -->

一切顺利,只是它只显示标签而没有显示内容的框。我希望其中一个内容默认可见。我不知道如何在不使用javaScript的情况下激活它。

先谢谢你。

1 个答案:

答案 0 :(得分:0)

将display:block添加为默认情况下要显示的div的样式。例如,看看我为在运行http://jsfiddle.net/X6Agf/

上显示item1而创建的这个小提琴
 <div style="display:block"><p>Tab Content 1</p></div>