2017-03-08 59 views
1

對不起,如果這已經被回答,我已經找到它了。響應上移列

我正在嘗試創建一個12列,響應式佈局。所有列都向左浮動。問題是我創建了一行,寬度爲100%。我想要下面的兩列。

  • 第1列:應該是一個導航菜單,具有錨

  • 第2欄:應該是所有用於演示

元素我置於行下面的2列。第1列相當短,並一直向下移動。第2列保持原樣。我想知道高度是否與它有關。所以我把兩列都做成了同一個高度。沒有幫助。 我也嘗試將沉沒列相對移動,這在桌面上看起來不錯,但在移動設備上看起來很糟糕。請指教。

該項目是在這裏:http://codepen.io/hherbst86/pen/OpbEzq

密碼(CSS和HTML):

CSS:

*{ 
    box-sizing: border-box; 
} 

.template-body{ 
    width: 100%; 
    min-width: 320px; 
    max-width: 1200px; 
    margin: 0 auto; 
} 

.row{ 
    padding: 20px; 
    width: 100%; 
    min-height: 1px; 
    float: left; 
} 

.col{ 
    min-height: 40px; 
    border-radius: 8px; 
    display: inline-block; 
    margin-right: -4px; 
} 

.col.one {width: 8.33333%;;} 
.col.two {width: 16.66667%;} 
.col.three {width: 25%;} 
.col.four {width: 33.33333%;} 
.col.five {width: 41.66667%;} 
.col.six {width: 50%;} 
.col.seven {width: 58.33333%;} 
.col.eight {width: 66.66667%;} 
.col.nine {width: 75%;} 
.col.ten {width: 83.33333%;} 
.col.eleven {width: 91.66667%;} 
.col.twelve {width: 100%;} 


@media (max-width: 768px){ 

    .col{ 
     width: 100% !important; 
    } 
} 

.col.three.index-panel{ 
    list-style-type: none; 
    height: 2000px; 
} 

.index-panel ul{ 
    list-style-type: none; 
} 

.index-panel ul li{ 
    border: 1px solid black; 
    padding: 20px; 
} 

HTML:

<head> 
    <title>Title Goes Here</title> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> 
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> 
    <link href="https://fonts.googleapis.com/css?family=Roboto+Slab|Roboto:300,400,700" rel="stylesheet"> 
    <link rel="stylesheet" href="styles/css/nascent.css"> 
    <style type="text/css"> 
     section { 
      height: 100px; 
      border: 1px solid black; 
     } 
    </style> 
</head> 

<body class="template-body"> 
    <div class="row"> 
    <header> 
     <img class="nascent-header__logo-image" src="images/BovAcademy_logo_head.png"> 
     <h1>Title Goes Here</h1> 
     <h3>Title Description</h3> 
    </header> 
    </div> 

    <div class="body-row row"> 

     <div class="col three index-panel"> 

       <nav class="index-panel"> 
       <ul>      
         <li><a href="#group01">Accordions</a></li> 
         <li><a href="#group02">Alerts</a></li> 
         <li><a href="#group03">Badges</a></li> 
         <li><a href="#group04">Breadcrumbs</a></li> 
         <li><a href="#group05">Buttons</a></li> 
         <li><a href="#group06">Cards</a></li> 
         <li><a href="#group07">Carousels</a></li> 
         <li><a href="#group08">Dropdowns</a></li> 
         <li><a href="#group09">Forms</a></li> 
         <li><a href="#group10">Footers</a></li> 
         <li><a href="#group11">List Groups</a></li> 
         <li><a href="#group12">Modals</a></li> 
         <li><a href="#group13">Pagination</a></li> 
         <li><a href="#group14">Progress Bar</a></li> 
         <li><a href="#group15">Tables</a></li> 
         <li><a href="#group16">Typography</a></li> 
       </ul> 
     </nav> 
     </div> 

     <div class = "col nine demo-sections"> 

      <section id="group01"> 
       <span><a href="#top">Go to top</a></span> 
      </section> 

      <section id="group02"> 
       <span><a href="#top">Go to top</a></span> 
      </section> 

      <section id="group03"> 
       <span><a href="#top">Go to top</a></span> 
      </section> 

      <section id="group04"> 
       <span><a href="#top">Go to top</a></span> 
      </section>     

      <section id="group05"> 
       <span><a href="#top">Go to top</a></span> 
      </section>     

      <section id="group06"> 
       <span><a href="#top">Go to top</a></span> 
      </section>     

      <section id="group07"> 
       <span><a href="#top">Go to top</a></span> 
      </section>     

      <section id="group08"> 
       <span><a href="#top">Go to top</a></span> 
      </section>     

      <section id="group09"> 
       <span><a href="#top">Go to top</a></span> 
      </section>     

      <section id="group10"> 
       <span><a href="#top">Go to top</a></span> 
      </section>     

      <section id="group11"> 
       <span><a href="#top">Go to top</a></span> 
      </section>     

      <section id="group12"> 
       <span><a href="#top">Go to top</a></span> 
      </section>     

      <section id="group13"> 
       <span><a href="#top">Go to top</a></span> 
      </section>     

      <section id="group14"> 
        <span><a href="#top">Go to top</a></span> 
      </section>       

      <section id="group15"> 
       <span><a href="#top">Go to top</a></span> 
      </section>  

      <section id="group16"> 
       <span><a href="#top">Go to top</a></span> 
      </section> 

      <section id="group17"> 
       <span><a href="#top">Go to top</a></span> 
      </section> 


      <section id="group18"> 
        <span><a href="#top">Go to top</a></span> 
      </section> 


      <section id="group19"> 
       <span><a href="#top">Go to top</a></span> 
      </section> 


      <section id="group20"> 
       <span><a href="#top">Go to top</a></span> 
      </section> 

     </div> 
</div> 

    <div class="row"></div> 

</body> 

回答

0

這是我的網格( 12)工作出色,style.css

body { 
    font-family: 'Nunito', sans-serif; 
    font-weight: 100; 
    font-size: 1em; /* 16px/16px = 1em */ 
    color: #000000; 
} 
.container{ 
    width: 90%; 
    max-width: 1200px; 
    padding: 0% 0; /* 0px/1200px = 0 */ 
    margin: 0 auto; 
} 

.container img { 
    width: 100%; 
} 

.grid1{ width:8.33333333333333%;float:left; }  /* 100px/1200px=0,0833333333333333=8,33333333333333% */ 
.grid2{ width: 16.66666666666667%;float:left; }   /* 200px/1200px=0,1666666666666667=16,66666666666667% */ 
.grid3{ width: 25%;float:left; }   /* 300px/1200px=0,25=25% */ 
.grid4{ width:33.33333333333333%;float:left; }   /* 400px/1200px=0,3333333333333333=33,33333333333333% */ 


.grid5{ width:41.66666666666667%;float:left; }  /* 500px/1200px=0,4166666666666667=41,66666666666667% */ 
.grid6{ width:50%; float:left; }    /* 600px/1200px=0,5=50% */ 
.grid7{ width:58.33333333333333%; float:left; }  /* 700px/1200px=0,5833333333333333=58,33333333333333% */ 
.grid8{ width:66.66666666666667%; float:left; }     /* 800px/1200px=0,6666666666666667=66,66666666666667% */ 
.grid9{ width:75%; float:left; }   /* 900px/1200px=0,75=75% */ 
.grid10{ width:83.33333333333333%; float:left; }    /* 1000px/1200px=0,8333333333333333=83,33333333333333% */ 
.grid11{ width:91.66666666666667%; float:left; }   /* 1100px/1200px=0,9166666666666667=91,66666666666667% */ 
.grid12{ width: 100%; float:left; }    /* 1200px/1200px=1=100% */ 

    @media screen and (max-width : 705px) { 
.grid1, 
.grid2, 
.grid3, 
.grid4, 
.grid5, 
.grid6, 
.grid7, 
.grid8, 
.grid9, 
.grid10, 
.grid11, 
.grid12 { 
    width: 100%; 
}} 

HTML文檔:

<!DOCTYPE html> 
<html lang="en-us"> 
<head> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<link rel="stylesheet" type="text/css" href="style.css"> 
</head> 
<body> 
<div class="container"> 
    <div class="grid12"> 
     First one row 
    </div> 
    <div class="grid6"> 
     Second row, first column 
    </div> 
    <div class="grid6"> 
     Second row, second column 
    </div> 
</div> 
</body> 
</html>