-3

我有一个结构为隐藏表格的页面(我尝试仅使用 div,但它不适合我).. 我在第二个单元格中有链接(我们称之为 A),它调用第一个单元格中的链接(我们称之为B)这将调用第二个单元格下的一个div部分(A下的一个段落)都在同一行内。

一切都很好,但是当我点击 A 时,B 链接显示正常,但使页面向上移动.. 当我点击隐藏 B 的按钮时,页面移回原来的位置..

我对此进行了很多搜索..大多数答案都是关于滚动的..我这样做是为了以防万一(即使我的问题是上下移动而不是左右移动)..但我仍然有问题..

请问有什么建议吗?

提前致谢..

更新:我真的做了很多研究..但似乎没有人遇到我面临的问题..另外,我试图操纵我的代码两天..请不要误判我:(

主表:

.myTable
{
  width: 100%;
  max-width: 1000px;
  float : left;        
  table-layout: auto;   
  overflow: hidden;
  /*border: 1px solid black; */
}

/*.myTable td {
    border-width: 2px;
    padding: 1px;
    border-style: inset;
    border-color: gray;
    background-color: white;
    -moz-border-radius: ;
  overflow: hidden;
} */
.myCenter
{
  width: 90%;
}
.tLeft
{
  width: 150px;
}
.myLeft
{

    text-align:left; /* This is only if you want the tab items at the center */          
    padding: 0;
    margin: 0;
    vertical-align: bottom;    /*
    position:relative;
    top: 100px;
    left: 0;             */
    visibility: hidden;display: none; 
    /*left:5px; 
    border: 3px solid green;  */

}
.myLeft:target
{

    text-align:left; /* This is only if you want the tab items at the center */          
    padding: 0;
    margin: 0;
    vertical-align: bottom;
    width: 150px;
    display: block;
    visibility:visible;
    float:left; /* no such thing as float center !!!*/
    position:relative;
    top: 0px;
    left: -43px;  
    /*left:5px;
    /*border: 1px solid green;*/    
}

.myLeft > ul.menuLeft
{
    list-style-type:none;
    display:block; /* Change this to block or inline for non-center alignment */      
    float: left;        
    vertical-align: bottom;
    /*border: 1px solid red;*/
}

.myLeft > ul.menuLeft > li > a
{
    color: #580000; /* #7a7883;  /* tabs titles */
    text-decoration:none;
    display:block;
    text-align:center;
    border:1px solid grey;   /* #3333FF border of the tabs */
    margin:2px;  
    width: 150px;       /* Width of the tabs */

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

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

}

.myLeft > ul.menuLeft > li > a:hover
{     
    color: white;   
    cursor:hand;     
}

.myLeft > ul.menuLeft > li > a:focus
{  
    color: #f5f9fc;  

}

.myLeft > ul.menuLeft > li:target > a
{
    cursor:default;
... 
}
.myLeft > ul.menuLeft > li:target > div
{
    display:block;
}

标签:

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

}
.tabs ul.menu
{
    list-style-type:none;
    display:inline; /* 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:none; /* no such thing as float center !!!*/
    vertical-align: bottom;   
   /** border: 1px solid yellow;  
    cursor:hand;                */

}
.tabs > ul.menu > li >  a
{
    color: #580000; /* #7a7883;  /* tabs titles */
    text-decoration:none;
    display:inline-block;
    text-align:center;
    border:1px solid #f1f3f4;   /* #3333FF border of the tabs */
    padding:5px 10px 5px 10px;  
    /*width: 25%;*/       /* Width of the tabs */

    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(#3333FF));
    /* Safari 5.1, Chrome 10+ */ background: -webkit-linear-gradient(top, #3333FF, #fff);  /* Firefox 3.6+ */   background: -moz-linear-gradient(top, #3333FF, #fff);
    /* IE 10 */ background: -ms-linear-gradient(top, #3333FF, #fff);  /* Opera 11.10+ */  background: -o-linear-gradient(top, #3333FF, #fff);    
}

.tabs ul.menu > li > a:hover
{     
    color: white;   
    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;
    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(#8A0808));

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

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

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

  /* Opera 11.10+ */
  background: -o-linear-gradient(top, #8A0808, #f1f3f4);  
}

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

内容:

<!-- content -->
<div class="content" style="height:350px; width:760px; ">
  <div class="tabs"  style="height:390px;"> <!-- Tabs --> 
  <ul class="menu">
    <li id="item-1"> <!-- item-1 -->        
      <a href="#left-1">Meetings</a>                        <!-- #f5f9fc --> 
       <div style="display:block; border:1px solid #f1f3f4; background-color: #3333FF; padding:10px; margin:0;  height:310px;">
          <h3 class="insideh"> Welcome </h3>
          <p  class="cl" style="font-size:18px; font-style: italic; padding: 5px 20px 5px 20px; ">
            Welcome welcome welcome <br>
            Please, enjoy the site and feel free to send us any comments you have.<br><br> Thank you.. 
          </p>
       </div> <!-- End of Welcome Div -->   
       <div style=" border:1px solid #f1f3f4; background-color: #3333FF; padding:10px; margin:0; height:310px;"  id="#item-1"> <!-- 222 --> 
        <div class="col" style="width:700px; display:inline;   ">  <!-- 111 -->
          <ul>           
            <li> <a class="alLink" href="aec2009.php">Meetings 2009</a> </li> 
            <li> <a class="alLink" href="aec2010.php">Meetings 2010</a> </li> 
            <li> <a class="alLink" href="aec2011.php">Meetings 2011</a> </li> 
            <li> <a class="alLink" href="aec2012.php">Meetings 2012</a> </li>  
            <li> <a class="alLink" href="aec2013.php">Meetings 2013</a> </li>  
            <li> <a class="alLink" href="">Miscellaneous</a> </li>
          </ul>
         </div> <!-- /111 -->     
      </div> <!-- end of Content #1 -->  <!-- /222 -->  
    </li> <!-- end of item-1 -->
    <li id="item-2">
      <a href="#left-2">Educational Materials</a>
      <div style="border:1px solid #f1f3f4; background-color: #3333FF; padding:10px; margin:0; height:310px;" id="#item-2"> <!-- 222 -->
        <div class="col" style="width:700px; display:inline;"> <!-- 111 -->
          <ul>           
            <li> <a class="alLink" href="aec2009.php">Our Books</a> </li> 
                <ul>           
                  <li> <a class="alLink" href="aec2009.php"> Books</a> </li> 
                  <li> <a class="alLink" href="aec2010.php"> Society</a> </li> 
                  <li> <a class="alLink" href="aec2011.php">Guidlines</a> </li> 
                </ul>   
            <li> <a class="alLink" href="aec2010.php"> Society</a> </li> 
            <li> <a class="alLink" href="aec2011.php">Guidlines</a> </li> 
          </ul>               
        </div>  <!-- /111 -->
      </div> <!-- end of Content #2 -->  <!-- /222 -->
    </li> <!-- end of item-2 -->
    <li id="item-3">
      <a href="#item-3">Event Calender 2013</a>
      <div style="border:1px solid #f1f3f4; background-color: #3333FF; padding:10px; margin:0; height:310px;" id="#item-3">  <!-- 111 -->
        <div class="col">
            <h3 class="insideh"> Date </h3>                 <p  class="cl" style="font-size:16px;">
            Jan 12th, 2013 <br>
            Apr 30th, 2013 <br> 
            Jul 10th, 2013 <br>                             </p>
        </div> 
        <div class="col">                                                        
            <h3 class="insideh"> Topics </h3>               <p  class="cl" style="font-size:16px;">                 
                              </p>                
        </div>
      </div> <!-- end of Content #3 -->  <!-- /111 -->
    </li> <!-- end of item-3 -->
    <li id="item-4">
      <a href="#item-4">AEC Members</a>
      <div style="border:1px solid #f1f3f4; background-color: #3333FF; padding:10px; margin:0; height:310px;"  id="#item-4">  <!-- 111 -->
       <h3 class="insideh"> Our Speaker Members </h3>

      </div> <!-- end of Content #4 --> <!-- /111 -->
    </li> <!-- end of item-4 -->         
    <li id="item-5">
      <a href="#item-5">Gallery</a>
      <div style="border:1px solid #f1f3f4; background-color: #3333FF; width: 99%; padding:10px; margin:0; height:310px;"  id="#item-5">  <!-- 111 -->

       <!--<?php /*include("gal1.html");  */?> -->   
      </div> <!-- end of Content #5 --> <!-- /111 -->
    </li> <!-- end of item-5 -->            
  </ul>     
  </div> <!-- end of Tabs -->         
</div>  <!-- end of content -->

指数:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html  xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">  
  <meta name="generator" content="PSPad editor, www.pspad.com">
  <meta name="viewport" content="width=device-width, maximum-scale=2.0" />
      <link href="css/main.css" rel="stylesheet" type="text/css" />
      <link href="css/text.css" rel="stylesheet" type="text/css" />  
      <link href="css/tabs.css" rel="stylesheet" type="text/css" />  
      <link href="css/buttons.css" rel="stylesheet" type="text/css" />
      <link href="css/tables.css" rel="stylesheet" type="text/css" />    
     <?php include 'counter.php' ?>  



  <title>The Echo Club</title>
  <LINK REL="SHORTCUT ICON" HREF="/imgs/icon.png" />
  </head>
  <body style= "overflow: scroll;">

<table class = "myTable">
  <tr> <!-- first row ****** Header SECTION ****** -->
      <?php include("htmls/header.html");  ?> 
  </tr> <!-- *** End of first row *** -->

  <tr> <!-- second row ****** Top NAVIGATION ******-->
      <td colspan = '3'> <!-- 2-first column -->
            <?php $page = 1; include("htmls/topnav.html");  ?>
      </td> <!-- End of 1-first col -->
      <!--<td> <!-- 2-second col ->
      </td> <!-- End of 1-second col ->
      <td> <!-- 2-third col ->
      </td> <!-- End of 2-third col -->
  </tr> <!-- *** End of second row *** -->

  <tr> <!-- third row ****** Search SECTION ******-->
      <td> <!-- 3-first column -->      
        <div class="myLeft"  style="height:300px; width: 150px;"><ul class="menuLeft">
                <li> &nbsp; </li> </ul> </div>    
      </td> <!-- End of 3-first col -->
      <!--<td> <!-- 3-second col ->
      </td> <!-- End of 3-second col -->
      <td colspan="2"> <!-- 3-third col -->          
          <?php include("htmls/search.html");  ?>  
      </td> <!-- End of 3-third col -->
  </tr> <!-- *** End of second row *** -->

  <tr> <!-- fourth row ****** Main SECTION ******-->
      <td> <!-- 4-first column -->
          <?php  include("htmls/leftNav.html");  ?> 
      </td> <!-- End of 4-first col -->
      <td class="myCenter"> <!-- 4-second col -->
          <?php include("htmls/content.html");  ?>        
      </td> <!-- End of 4-second col -->
      <td> <!-- 4-third col -->
          <!-- <iframe style="width:170px;  height:300px; margin: 0 1% 0 1%;"  frameborder="1" allowfullscreen></iframe> -->  
          <img src="imgs/myAD.jpg" />        
          <?php include("htmls/newsLetters.html");  ?> 
      </td> <!-- End of 4-third col -->
  </tr> <!-- *** End of fourth row *** -->

    <tr> <!-- fifth row ****** Sociel Network SECTION ******-->
      <td> <!-- 5-first column -->           
      </td> <!-- End of 5-first col -->
      <td> <!-- 5-second col -->
          <?php include("htmls/social.html"); ?>  
      </td> <!-- End of 5-second col -->
      <td> <!-- 5-third col -->          
      </td> <!-- End of 5-third col -->
  </tr> <!-- *** End of fifth row *** -->

    <tr> <!-- sixth row ****** Footer SECTION ******-->
      <!--<td> <!-- 6-first column ->          
      </td> <!-- End of 6-first col -->
      <td class="myCenter" colspan = '3'> <!-- 6-second col -->
          <?php include("htmls/footer.html");  ?>  
      </td> <!-- End of 6-second col -->
       <!--<td><!-- 6-third col ->
      </td> <!-- End of 6-third col -->
  </tr> <!-- *** End of sixth row *** -->
</table>  

  </body>
</html>
4

2 回答 2

1

(我尝试只使用 div,但它不适合我)

太糟糕了,我敢肯定谷歌不会善待糟糕或完全错误的 HTML 语义,因为他们一直在试图理解你的内容(假设你有内容)是关于什么的。换句话说:如果你不打算以正确的方式去做,那么就不要费心去做。除非您有表格数据并且页面布局不是表格数据,否则您根本不应该使用table元素。

但我会试着让你走上正确的道路。我已经为那些不了解使用除法元素和 CSS 级别 1 的基本布局的人创建了一个基本的 CSS 级别 1 教程。很多“专业人士”使用 CSS 级别 2 位置之类的东西,如果你阅读并练习你'尽管您会远远领先于一些自封的专业人士,但您不仅会发现它适合您。如果您之后有任何问题,请随时问我。说真的,当你坚持以正确的方式做事时,你会惊讶于你能做多少事情。

http://www.jabcreations.com/web/css/nested-divisible-elements

于 2013-09-12T08:20:39.463 回答
0

好吧..经过长时间的听力疼痛后,我终于明白了..我会列出它以供将来的提问者使用..

我所要做的就是将它包含在一个稳定的容器 div 中。像这样:

<div style="height:350px; width: 150px; "> <!-- Left Container -->
    <div id = "left-1" class="myLeft"  style="height:300px;" > <!-- Tabs --> 
      <ul class="menuLeft"  >
                <li> <a class="alLink" href="#item-1" >bla bla..</a> </li> 

      </ul>
  </div>
  <div id = "left-2" class="myLeft"  style="height:300px;" > <!-- Tabs --> 
      <ul class="menuLeft">
                <li> <a class="alLink" href="#item-1">bla bla..</a> </li> 
                <li> <a class="alLink" href="#item-2">bla bla..</a> </li> 

      </ul>
  </div>
 </div>

而不是以下内容:

<div id = "left-1" class="myLeft"  style="height:300px;" > <!-- Tabs --> 
          <ul class="menuLeft"  >
                    <li> <a class="alLink" href="#item-1" >bla bla..</a> </li> 

          </ul>
      </div>
      <div id = "left-2" class="myLeft"  style="height:300px;" > <!-- Tabs --> 
          <ul class="menuLeft">
                    <li> <a class="alLink" href="#item-1">bla bla..</a> </li> 
                    <li> <a class="alLink" href="#item-2">bla bla..</a> </li> 

          </ul>
      </div>

它真的显示了我是多么的新手:s

于 2013-09-18T20:33:57.747 回答