2016-12-12 13 views
0

次のサイトに関連して上だけで簡単に:子要素 "row"が親要素 "container"の高さと一致しないのはなぜですか?

christmas.drcrittall.com

私の質問は、なぜ以下のCSSにもかかわらず、である:

html, body { 

    height:100%; 

} 

/* Background image for website */ 
body { 

    /*background: url("images/crumpled.jpg") no-repeat center center fixed;*/ 
    background: url("../img/crumpled.jpg") no-repeat; 
    background-size: 100% 100%; 
    /*margin-bottom:5%;*/         

} 

#header { 

    height:20%; 
    border-style: solid; 
    border-color:red; 
    /*padding:0px; */      

} 

#middle { 

    height:60%; 
    /* border-style: solid; 
    border-color:green;*/ 

} 

#cap { 

    height:20%; 

    border-style: solid; 
    border-color:blue; 
    /* Previously the click here text was overflowing out of this div. See here to see how to deal with this: https://css-tricks.com/almanac/properties/o/overflow/ */ 
    /*overflow:auto;*/. 

} 

#form { 

    min-height:20%; /* Setting min-height of white-space beneath body enables container to expand with the form as it gets bigger */ 
    display:none; /* This div is initially hidden until click button which activates jquery animation */ 


} 

#main_image { 


    max-width:100%; 
    max-height:60vh; /*Set max and min heights to 60vh to lock within this container ie stop images expanding out */ 
    min-height:60vh; 

} 

#candle_image { 

    width:100%; 
    height:100%; 

} 

#top_paper { 

    width:100%; 
    max-height:100%; 


} 

/* Make row height and columns fill entire height of containers */ 

.row, .col-md-6, .col-md-4, .col-md-6, .col-md-12, .col-md-8, .col-md-2, .col-md-3, { 

    height:100%; 

} 

は#cap内の行をし、記入しない#head高さの100%?私は、ヘッダー内のフォントを中央にフレックスボックスを使用していたが、キャップと同じことを行うように見えることはできません...ここではHTMLです:

<body> 
    <div class = "container-fluid center_font" id = "header"> 
     <div class = "row" style = "border-style: solid; border-color:black;"> 
      <div class = "col-md-12 col-xs-12"> 
       <font id = "dear"> Merry Christmas! </font> 
      </div> 
     </div> 
    </div> 
    <div class = "container-fluid center_font" id = "middle"> 
     <div class = "row"><!-- style = "border-style:solid; border-color:black;">--> 
      <div class = "col-md-3" id = "holly_1" style = "padding-top:10%;"> 
       <img src = "../img/candles.png" id = "candle_image" class = "img-fluid">  
      </div> 
      <div class = "col-md-6 col-xs-12 center_font"><!-- style = "border-style:solid; border-color:yellow;">--> 
       <img src = "" id = "main_image" class = "img-circle"> 
      </div> 
      <div class = "col-md-3" id = "holly_2" style = "padding-top:10%;"> 
       <img src = "../img/candles.png" id = "candle_image" class = "img-fluid">  
      </div> 
     </div> 
    </div> 
    <div class = "container-fluid" id = "cap"><!-- style = "border-style:solid; border-color:green;">--> 
     <div class = "row" style = "border-style: solid; border-color:black;"> 
      <div class = "col-md-offset-3 col-md-6 col-xs-12 center_font">     
       <font class = "ammend" id = "dear" style = "font-size:45px;"> Love from Matthew</font><br> 
       <!--<a href = "#" id = "reveal"> 
        <font id = "dear" class = "fiddle" style = "font-size: 20px;">Click Me</font> 
       </a> 
       --> 
      </div> 
      <div class = "col-md-offset-3 col-md-6 col-xs-12 center_font"> 
       <a href = "#" id = "reveal"> 
        <font id = "dear" class = "fiddle" style = "font-size: 20px;">Click Me</font> 
       </a> 
      </div> 
     </div>  
    </div> 
</body> 

答えて

1

フォントサイズが大きすぎるとオフセット列を崩壊、 #capcenter_fontクラスがありません。

  • #capcenter_fontクラスを追加します。
  • font-size45pxから36px,font#dear.ammendに変更して、1行のテキスト( "Love from Matthew")を保持します。物事がはるかに優れて見えるようん

Check image

+0

ありがとう!私はしかし、いくつかの質問がありました。まず、なぜフォントのために36?第2に、そのクラスが100%に設定されているにもかかわらず、行の高さがコンテナの高さと一致しないのはなぜですか? – Mathias

+0

font-sizeとして45pxを残してcenter_fontを追加すると、すべてのコンテナの高さをカバーすることがわかります。36pxは1行を保存するための制限ですが、望むように調整します。解決。ヘッダーに1行を使用した場合、1行も必要であると仮定した場合、テキストにはもう少し息が吹きます。それ以外の場合は、絵が非常にタイトです。 :) – Syden

関連する問題