2015-07-27 4 views
0

Я пытался решить свою проблему в течение нескольких часов, но это не кажется слишком ясным. У меня есть изображение заголовка и панель навигации. Мне нужно, чтобы панель навигации отображалась под заголовком, однако она продолжает показывать ее сверху.Раздел не отображается под заголовком

CSS:

html, body, div, span, applet, object, iframe, 
h1, h2, h3, h4, h5, h6, p, blockquote, pre, 
a, abbr, acronym, address, big, cite, code, 
del, dfn, em, img, ins, kbd, q, s, samp, 
small, strike, strong, sub, sup, tt, var, 
b, u, i, center, 
dl, dt, dd, ol, ul, li, 
fieldset, form, label, legend, 
table, caption, tbody, tfoot, thead, tr, th, td, 
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary, 
time, mark, audio, video { 
    margin: 0; 
    padding: 0; 
    border: 0; 
    font: inherit; 
    font-size: 100%; 
    vertical-align: baseline; 
} 

html { 
    line-height: 1; 
} 

ol, ul { 
    list-style: none; 
} 

table { 
    border-collapse: collapse; 
    border-spacing: 0; 
} 

caption, th, td { 
    text-align: left; 
    font-weight: normal; 
    vertical-align: middle; 
} 

q, blockquote { 
    quotes: none; 
} 
q:before, q:after, blockquote:before, blockquote:after { 
    content: ""; 
    content: none; 
} 

a img { 
    border: none; 
} 

article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { 
    display: block; 
} 

@font-face { 
    font-family: Fragment; 
    src: url("../fonts/Fragmentcore.otf"); 
} 
.site-nav { 
    position: absolute; 
    left: 100px; 
    outline: 1px solid; 
    background: #fff; 
    width: 12%; 
    text-align: center; 
    height: 100%; 
} 
.site-nav li { 
    margin: 0.97em 0.8em 0 0.8em; 
    border-bottom: 1px dotted; 
    padding-top: 6px; 
    padding-bottom: 6px; 
} 
.site-nav a { 
    color: black; 
    font-size: 1.25em; 
    text-decoration: none; 
    font-family: 'Fragment'; 
    font-weight: bold; 
} 
.site-nav li:hover { 
    background: rgba(0, 0, 0, 0.8); 
    border-bottom-color: #fff; 
} 
.site-nav li:hover a { 
    color: #fff; 
} 
@media screen and (max-width: 768px) { 
    .site-nav { 
    left: 85px; 
    width: 19%; 
    } 
} 

header { 
    position: absolute; 
    height: 100%; 
    width: 100%; 
    background-size: cover; 
} 

.header-container { 
    position: absolute; 
    z-index: -1; 
    background-color: white; 
    background: url(../img/bg.jpg) no-repeat bottom center scroll; 
    background-size: cover; 
    width: 100%; 
    height: 100%; 
    /*@media screen and (min-width: $size-small){ 
     height: 100%; 
     padding: 0; 
    }*/ 
} 

h1 { 
    text-align: center; 
    font-size: 1.7em; 
    font-family: 'Fragment'; 
    font-weight: bold; 
    margin-top: 45px; 
    margin-bottom: 42px; 
} 

HTML:

<body> 
    <header> 
     <div class="header-container"></div> 
    </header> 

    <section id="content"> 
     <nav class="site-nav"> 
      <h1>Chronology</h1> 
      <ul> 
       <li><a href="#">Home</a></li> 
       <li><a href="#">Photos</a></li> 
       <li><a href="#">Art</a></li> 
       <li><a href="#">About</a></li> 
       <li><a href="#">Contact</a></li> 
      </ul> 
     </nav> 
    </section> 
</body> 

Любая помощь приветствуется. Спасибо :)

+0

Вы хотите, чтобы заголовок взять 100% экрана ?, Я спрашиваю потому, что этого 'заголовка {высота: 100%;}' –

+0

Что Я хочу сделать что-то вроде этого: http://ironsummitmedia.github.io/startbootstrap-grayscale/ –

+0

Как вы можете видеть, заголовок при просмотре выглядит покрывающим всю страницу, а затем, когда вы прокручиваете вниз, появляются другие элементы ! –

ответ

0

Попробуйте добавить height: 100% в html, body, удалить position: absolute из header и установить top: 100% в .site-nav так:

html, body, div, span, applet, object, iframe, 
 
h1, h2, h3, h4, h5, h6, p, blockquote, pre, 
 
a, abbr, acronym, address, big, cite, code, 
 
del, dfn, em, img, ins, kbd, q, s, samp, 
 
small, strike, strong, sub, sup, tt, var, 
 
b, u, i, center, 
 
dl, dt, dd, ol, ul, li, 
 
fieldset, form, label, legend, 
 
table, caption, tbody, tfoot, thead, tr, th, td, 
 
article, aside, canvas, details, embed, 
 
figure, figcaption, footer, header, hgroup, 
 
menu, nav, output, ruby, section, summary, 
 
time, mark, audio, video { 
 
    margin: 0; 
 
    padding: 0; 
 
    border: 0; 
 
    font: inherit; 
 
    font-size: 100%; 
 
    vertical-align: baseline; 
 
    box-sizing: border-box; 
 
} 
 

 
html { 
 
    line-height: 1; 
 
} 
 

 
html, body{ /*added*/ 
 
    height: 100%; 
 
} 
 

 
ol, ul { 
 
    list-style: none; 
 
} 
 

 
table { 
 
    border-collapse: collapse; 
 
    border-spacing: 0; 
 
} 
 

 
caption, th, td { 
 
    text-align: left; 
 
    font-weight: normal; 
 
    vertical-align: middle; 
 
} 
 

 
q, blockquote { 
 
    quotes: none; 
 
} 
 
q:before, q:after, blockquote:before, blockquote:after { 
 
    content: ""; 
 
    content: none; 
 
} 
 

 
a img { 
 
    border: none; 
 
} 
 

 
article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { 
 
    display: block; 
 
} 
 

 
@font-face { 
 
    font-family: Fragment; 
 
    src: url("../fonts/Fragmentcore.otf"); 
 
} 
 
.site-nav { 
 
    position: absolute; 
 
    left: 100px; 
 
    border: 1px solid; 
 
    background: #fff; 
 
    width: 12%; 
 
    text-align: center; 
 
    top: 100%; /*added*/ 
 
    
 
} 
 
.site-nav li { 
 
    margin: 0.97em 0.8em 0 0.8em; 
 
    border-bottom: 1px dotted; 
 
    padding-top: 6px; 
 
    padding-bottom: 6px; 
 
} 
 
.site-nav a { 
 
    color: black; 
 
    font-size: 1.25em; 
 
    text-decoration: none; 
 
    font-family: 'Fragment'; 
 
    font-weight: bold; 
 
} 
 
.site-nav li:hover { 
 
    background: rgba(0, 0, 0, 0.8); 
 
    border-bottom-color: #fff; 
 
} 
 
.site-nav li:hover a { 
 
    color: #fff; 
 
} 
 
@media screen and (max-width: 768px) { 
 
    .site-nav { 
 
    left: 85px; 
 
    width: 19%; 
 
    } 
 
} 
 

 
header { 
 
    /*position: absolute;*/ /*removed*/ 
 
    height: 100%; 
 
    width: 100%; 
 
    background-size: cover; 
 
} 
 

 
.header-container { 
 
    position: absolute; 
 
    z-index: -1; 
 
    background-color: white; 
 
    background: url(http://i.stack.imgur.com/gijdH.jpg?s=328&g=1) no-repeat bottom center scroll; 
 
    background-size: cover; 
 
    width: 100%; 
 
    height: 100%; 
 
    /*@media screen and (min-width: $size-small){ 
 
     height: 100%; 
 
     padding: 0; 
 
    }*/ 
 
} 
 

 
h1 { 
 
    text-align: center; 
 
    font-size: 1.7em; 
 
    font-family: 'Fragment'; 
 
    font-weight: bold; 
 
    margin-top: 45px; 
 
    margin-bottom: 42px; 
 
}
<header> 
 
     <div class="header-container"></div> 
 
    </header> 
 

 
    <section id="content"> 
 
     <nav class="site-nav"> 
 
      <h1>Chronology</h1> 
 
      <ul> 
 
       <li><a href="#">Home</a></li> 
 
       <li><a href="#">Photos</a></li> 
 
       <li><a href="#">Art</a></li> 
 
       <li><a href="#">About</a></li> 
 
       <li><a href="#">Contact</a></li> 
 
      </ul> 
 
     </nav> 
 
    </section>

Во всяком случае еще лучше удаления position: absolute из .site-nav и пусть это следуйте потоку документа, я комментирую изменение в css. Я очень рекомендую вам следующее:

html, body, div, span, applet, object, iframe, 
 
h1, h2, h3, h4, h5, h6, p, blockquote, pre, 
 
a, abbr, acronym, address, big, cite, code, 
 
del, dfn, em, img, ins, kbd, q, s, samp, 
 
small, strike, strong, sub, sup, tt, var, 
 
b, u, i, center, 
 
dl, dt, dd, ol, ul, li, 
 
fieldset, form, label, legend, 
 
table, caption, tbody, tfoot, thead, tr, th, td, 
 
article, aside, canvas, details, embed, 
 
figure, figcaption, footer, header, hgroup, 
 
menu, nav, output, ruby, section, summary, 
 
time, mark, audio, video { 
 
    margin: 0; 
 
    padding: 0; 
 
    border: 0; 
 
    font: inherit; 
 
    font-size: 100%; 
 
    vertical-align: baseline; 
 
} 
 

 
html { 
 
    line-height: 1; 
 
} 
 

 
html, body{ 
 
    height: 100%; 
 
} 
 

 
ol, ul { 
 
    list-style: none; 
 
} 
 

 
table { 
 
    border-collapse: collapse; 
 
    border-spacing: 0; 
 
} 
 

 
caption, th, td { 
 
    text-align: left; 
 
    font-weight: normal; 
 
    vertical-align: middle; 
 
} 
 

 
q, blockquote { 
 
    quotes: none; 
 
} 
 
q:before, q:after, blockquote:before, blockquote:after { 
 
    content: ""; 
 
    content: none; 
 
} 
 

 
a img { 
 
    border: none; 
 
} 
 

 
article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { 
 
    display: block; 
 
} 
 

 
@font-face { 
 
    font-family: Fragment; 
 
    src: url("../fonts/Fragmentcore.otf"); 
 
} 
 
.site-nav { 
 
    /*position: absolute;*/ /*removed*/ 
 
    /*left: 100px;*/ /*removed*/ 
 
    /*width: 12%;*/ 
 
    display: inline-block; /*added*/ 
 
    margin-left: 100px; 
 
    border: 1px solid; 
 
    background: #fff; 
 
    text-align: center; 
 
    top: 100%; /*added*/ 
 
    
 
} 
 
.site-nav li { 
 
    margin: 0.97em 0.8em 0 0.8em; 
 
    border-bottom: 1px dotted; 
 
    padding-top: 6px; 
 
    padding-bottom: 6px; 
 
} 
 
.site-nav a { 
 
    color: black; 
 
    font-size: 1.25em; 
 
    text-decoration: none; 
 
    font-family: 'Fragment'; 
 
    font-weight: bold; 
 
} 
 
.site-nav li:hover { 
 
    background: rgba(0, 0, 0, 0.8); 
 
    border-bottom-color: #fff; 
 
} 
 
.site-nav li:hover a { 
 
    color: #fff; 
 
} 
 
@media screen and (max-width: 768px) { 
 
    .site-nav { 
 
    margin-left: 85px; 
 
    } 
 
} 
 

 
header { 
 
    /*position: absolute;*/ /*removed*/ 
 
    height: 100%; 
 
    width: 100%; 
 
    background-size: cover; 
 
} 
 

 
.header-container { 
 
    position: absolute; 
 
    z-index: -1; 
 
    background-color: white; 
 
    background: url(http://i.stack.imgur.com/gijdH.jpg?s=328&g=1) no-repeat bottom center scroll; 
 
    background-size: cover; 
 
    width: 100%; 
 
    height: 100%; 
 
    /*@media screen and (min-width: $size-small){ 
 
     height: 100%; 
 
     padding: 0; 
 
    }*/ 
 
} 
 

 
h1 { 
 
    text-align: center; 
 
    font-size: 1.7em; 
 
    font-family: 'Fragment'; 
 
    font-weight: bold; 
 
    margin-top: 45px; 
 
    margin-bottom: 42px; 
 
    margin-top: 0; 
 
}
<header> 
 
     <div class="header-container"></div> 
 
    </header> 
 

 
    <section id="content"> 
 
     <nav class="site-nav"> 
 
      <h1>Chronology</h1> 
 
      <ul> 
 
       <li><a href="#">Home</a></li> 
 
       <li><a href="#">Photos</a></li> 
 
       <li><a href="#">Art</a></li> 
 
       <li><a href="#">About</a></li> 
 
       <li><a href="#">Contact</a></li> 
 
      </ul> 
 
     </nav> 
 
    </section>

+0

@bgm Сообщите мне, если это поведение, которое вы хотите: 'header' занимает 100% экрана, '.content', включая' .site-nav', находится под заголовком 'header' –

Смежные вопросы