2016-12-28 86 views
1

我對柔性箱很陌生。我似乎無法弄清楚的是如何將div放置到柔性容器的底部。我搜索堆棧溢出的解決方案,但沒有任何工作。很明顯,我做錯了什麼。將柔性物品放置到柔性容器的底部

所以在div 頭底應被定位在容器的底部。任何幫助都感激不盡。提前致謝。

HTML

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <meta charset="utf-8"> 
     <meta name="author" content=""> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 

     <title>Website</title> 

     <!-- STYLESHEETS --> 
     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"> 
     <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 

     <!-- FONTS --> 
     <link href="https://fonts.googleapis.com/css?family=Playball|Raleway: 300,900" rel="stylesheet"> 
     <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet"> 

     <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> 
     <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> 
     <!--[if lt IE 9]> 
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> 
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
     <![endif]--> 
    </head> 
    <body> 
    <div class="wrapper"> 
     <header class="header"> 
      <div class="header-logo"> 
       <a href="/"> 
        <img class="header-logo-img" src="http://placehold.it/100x100" alt=""> 
       </a> 
      </div> 
      <nav class="header-nav-primary" role="navigation"> 
       <ul class="nav-primary-items"> 
        <li class="nav-primary-item"> 
         <a class="nav-primary-link" href="#home">Home</a> 
        </li> 
        <li class="nav-primary-item"> 
         <a class="nav-primary-link" href="#menu">Menu</a> 
        </li> 
        <li class="nav-primary-item"> 
         <a class="nav-primary-link" href="#over">Over</a> 
        </li> 
        <li class="nav-primary-item"> 
         <a class="nav-primary-link" href="#contact">Contact</a> 
        </li> 
       </ul> 
      </nav> 
      <div class="header-bottom"> 
       <div class="social-media"> 
        <a href="http://www.facebook.be" target="_blank"> 
         <i class="fa fa-facebook fa-lg" aria-hidden="true"></i> 
        </a> 
        <a href="http://www.instagram.be" target="_blank"> 
         <i class="fa fa-instagram fa-lg" aria-hidden="true"></i> 
        </a> 
       </div> 
       <div class="address"> 
        <p>Diestsesteenweg ###<br>3010 Kessel-Lo<br>###/## ## ##</p> 
       </div> 
      </div> 
     </header> 
     <main class="main"> 
      <section id="home"></section> 
      <section id="menu"></section> 
      <section id="over"></section> 
      <section id="contact"></section> 
     </main> 
    </div> 
    </body> 
</html> 

CSS

body { 
    min-width: 320px; 
    background-color: #fff; 
    font-family: 'Montserrat', sans-serif; 
    color: #f1ebda; 
    font-size: 1.5rem; 
    font-weight: 300; 
    line-height: 1.8; 
} 

.wrapper { 
    display: -webkit-box; 
    display: -webkit-flex; 
    display: -ms-flexbox; 
    display: flex; 
    -webkit-box-orient: vertical; 
    -webkit-box-direction: normal; 
    -webkit-flex-direction: column; 
    -ms-flex-direction: column; 
    flex-direction: column; 
    min-width: 100vw; 
    min-height: 100vh; 
} 

.header { 
    padding: 2.75rem; 
    background-color: #303030; 
} 

.header-logo { 
    display: -webkit-box; 
    display: -webkit-flex; 
    display: -ms-flexbox; 
    display: flex; 
    -webkit-box-pack: center; 
    -webkit-justify-content: center; 
    -ms-flex-pack: center; 
    justify-content: center; 
    margin-bottom: 5.625rem; 
} 

.nav-primary-items { 
    display: -webkit-box; 
    display: -webkit-flex; 
    display: -ms-flexbox; 
    display: flex; 
    -webkit-flex-flow: row wrap; 
    -ms-flex-flow: row wrap; 
    flex-flow: row wrap; 
    -webkit-box-pack: center; 
    -webkit-justify-content: center; 
    -ms-flex-pack: center; 
    justify-content: center; 
    list-style: none; 
    margin: 0 0 1.250rem 0; 
    padding: 0; 
} 

.nav-primary-item { 
    margin: 0 .4rem; 
} 

.nav-primary-link { 
    display: inline-block; 
    padding: 0 .4rem; 
    text-transform: uppercase; 
    letter-spacing: 0.188rem; 
    font-size: 1.1rem; 
} 

.header-bottom { 
    text-align: center; 
} 

.social-media i { 
    margin-right: 1.250rem; 
} 

.address p { 
    margin: 1.250rem 0 0 0; 

} 

.main { 
    overflow: auto; 
    padding: 4.45rem 2.75rem; 
} 

h1, h2, h3, h4, h5, h6 { 
    margin: 0 0 1.05rem; 
    padding: 0; 
    color: #111; 
    font-weight: 700; 
    line-height: 1.2; 
    font-family: 'Playball', sans-serif; 
} 

a { 
    text-decoration: none; 
    color: #f1ebda; 
} 

a:active, 
a:hover, 
a:focus { 
    color: #f1ebda; 
    text-decoration: none; 
} 

@media (min-width: 840px) { 
    .wrapper { 
     -webkit-box-orient: horizontal; 
     -webkit-flex-direction: row; 
     -ms-flex-direction: row; 
     flex-direction: row; 
     overflow: hidden; 
     height: 100vh; 
    } 

    .header { 
     -webkit-box-flex: 0; 
     -webkit-flex: 0 0 32rem; 
     -ms-flex: 0 0 32rem; 
     flex: 0 0 32rem; 
     padding: 4.45rem 2.75rem; 
     max-width: 32rem; 
    } 

    .header-nav-primary { 
     margin-bottom: 2.75rem; 
    } 

    .nav-primary-items { 
     -webkit-flex-flow: column nowrap; 
     -ms-flex-flow: column nowrap; 
     flex-flow: column; 
     text-align: center; 
    } 

    .nav-primary-item { 
     margin-bottom: 3.125em; 
    } 

    .nav-primary-link { 
     display: block; 
     padding: .4rem; 
    } 

    .main { 
     -webkit-box-flex: 1; 
     -webkit-flex: 1; 
     -ms-flex: 1; 
     flex: 1; 
     padding: 4.45rem; 
    } 
} 
+0

可能的重複:http://stackoverflow.com/questions/31000885/align-an-element-to-bottom-with-flexbox – sol

+1

不知道是什麼問題。 '.header-bottom' div實際上位於'.header'容器的底部(即使在媒體查詢中):https://jsfiddle.net/9bckrv3q/1/ –

+0

在新窗口中打開它。它不是定位在底部...... – Sven

回答