2016-08-28 3 views
1

Я пытаюсь переполнить div над другим, устанавливая 100% экрана.Ребенок div переполняет родительский div

На моем примере я бы хотел, чтобы красный бар, где О нас, переполняет граничный div, устанавливающий 100% экрана.

HTML:

<div id="wrapper"> 
    <!-- header of the page --> 
    <header id="header"> 
     <div class="container"> 
      <div class="row"> 
       <div class="col-xs-12 holder"> 
        <!-- logo of the page --> 
        <a href="#" class="nav-opener visible-xs"><i class="fa fa-bars"></i></a>       
        <div class="nav-holder"> 
         <!-- nav of the page --> 
         <nav id="nav"> 
          <ul class="list-inline"> 
           <li><a href="index.html">Home</a></li> 
           <li class="active"><a href="quemsomos.html">About Us</a></li> 
           <li><a href="area-atuacao.html">Area</a></li> 
           <li><a href="servicos.html">Services</a></li> 
           <li><a href="contato.html">Contact</a></li> 
          </ul> 
         </nav> 
        </div> 
       </div> 
      </div> 
     </div> 
    </header> 
    <!-- banner-block of the Page --> 
    <div class="banner-block"> 
     <div class="container"> 
      <div class="row row-about"> 
       <div class="col-xs-12 banner-box"> 
        <header class="banner-heading"> 
         <h1>About Us</h1> 
        </header> 
       </div> 
      </div> 
     </div> 
    </div> 
    <!-- contain main informative part of the site --> 
</div> 

CSS:

.banner-block { 
    overflow: hidden; 
    position: relative; 
} 

.banner-block:after { 
    position: absolute; 
    content: ""; 
    top: 0; 
    bottom: 0; 
    left: 0; 
    right: 0; 
} 

.banner-block:after { 
    z-index: -1; 
    background: rgba(0, 0, 0, .6); 
} 

.banner-block .bg-stretch { 
    z-index: -1; 
} 

.banner-block.centercenter-block { 
    text-align: center; 
} 

.banner-block.right-block { 
    text-align: right; 
} 

.banner-box { 
    height: 252px; 
    padding-top: 158px; 
    white-space: nowrap; 
} 

.banner-box .banner-heading { 
    display: inline-block; 
    white-space: normal; 
    vertical-align: middle; 
} 

.banner-box:before { 
    content: ""; 
    vertical-align: middle; 
    display: inline-block; 
    height: 100%; 
    width: 1px; 
    overflow: hidden; 
    margin: 0 0 0 -5px; 
} 

.row-about { 
    background: red; 
} 
.banner-heading { 
    margin: 11px 0 0; 
    position: absolute; 
} 

.banner-heading h1 { 
    margin: -70px 120px 15px; 
    color: #fff; 
    text-transform: uppercase; 
    font-size: 36px; 
    line-height: 40px; 
} 
#wrapper { 
    position: relative; 
    overflow: hidden; 
    border: 1px solid black; 
    margin:20px; 
} 

#header { 
    bottom: auto; 
    z-index: 9999; 
    background: #fff; 
} 

http://jsfiddle.net/dempc3go

+0

Извините, но ваш вопрос не совсем ясно –

+0

я хочу красный ДИВ, чтобы выйти из черной окантовкой .. что понятнее? – dante

ответ

0

Красная полоса по середине конструкции, указанной можно рассматривать как совершенно отдельный элемент к остальной части дизайн. Вы можете сделать что-то вроде этого:

.red-tape { 
    top: 50px; 
    height: 80px; 
    left: 0; 
    right: 0; 
    top: 70px; 
    background-color: red; 
    position: absolute; 
} 

.container { 
    border: 1px solid black; 
    height: 500px; 
    width: 800px; 
    margin: 0 auto; 
    position: relative; 
} 

ul { 
    float: right; 
} 

ul li { 
    display: inline-block; 
} 

Codepen example

+0

Я хочу, чтобы красный div вышел из черной границы ... – dante

+0

@dante Итак, удалите границу из обертки и добавьте ее в заголовок - http://jsfiddle.net/dempc3go/3/ – alanbuchanan

+0

взгляните на это .., чтобы быть яснее пожалуйста .. http://gilbertogm.xyz/1.png – dante

0

как я понял ваш вопрос. вы используете класс .container. который имеет ширину width: 750px;. Так оно не позволить ему расти до 100%,

<div class="banner-block"> 
     <div class="container"> 
      --- 
     </div> 
</div> 
+0

хм, но как было бы исправить? я достал контейнер div, но я до сих пор не могу его правильно – dante

0

Кроме того, если я правильно понимаю ваш вопрос, чтобы соответствовать весь экран, вы можете удалить поля и границы от #wrapper, что сделало бы ваш «о нас "раздел подходит для всего экрана.

http://jsfiddle.net/dempc3go/2/

CSS:

.banner-block { 
    overflow: hidden; 
    position: relative; 
} 

.banner-block:after { 
    position: absolute; 
    content: ""; 
    top: 0; 
    bottom: 0; 
    left: 0; 
    right: 0; 
} 

.banner-block:after { 
    z-index: -1; 
    background: rgba(0, 0, 0, .6); 
} 

.banner-block .bg-stretch { 
    z-index: -1; 
} 

.banner-block.centercenter-block { 
    text-align: center; 
} 

.banner-block.right-block { 
    text-align: right; 
} 

.banner-box { 
    height: 252px; 
    padding-top: 158px; 
    white-space: nowrap; 
} 

.banner-box .banner-heading { 
    display: inline-block; 
    white-space: normal; 
    vertical-align: middle; 
} 

.banner-box:before { 
    content: ""; 
    vertical-align: middle; 
    display: inline-block; 
    height: 100%; 
    width: 1px; 
    overflow: hidden; 
    margin: 0 0 0 -5px; 
} 

.row-about { 
    background: red; 
} 
.banner-heading { 
    margin: 11px 0 0; 
    position: absolute; 
} 

.banner-heading h1 { 
    margin: -70px 120px 15px; 
    color: #fff; 
    text-transform: uppercase; 
    font-size: 36px; 
    line-height: 40px; 
} 
#wrapper { 
    position: relative; 
    overflow: hidden; 
} 

#header { 
    bottom: auto; 
    z-index: 9999; 
    background: #fff; 
} 
+0

Но я хочу сохранить границу .. – dante

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