2016-03-25 14 views
0

素材デザインとウェブサイトを設計していますが、ページコンテンツのdiv間にスペースがある理由を理解できません。私は自分のセクションのいずれかに新しいdivを追加しているので、前のdivとヘッダーの間に空白を作成します。ご提案のために事前に素材設計Lite div間の空白

demo-layout-transparent .mdl-layout__header, 
 
.demo-layout-transparent .mdl-layout__drawer-button { 
 
    color: white; 
 
} 
 

 
.mdl-layout-title { 
 
    font-family: 'League Spartan'; 
 
    font-size: 2em; 
 
    margin-top: 5px; 
 
} 
 

 
.Home-section h1{ 
 
    color: floralwhite; 
 
    font-family: 'League Spartan'; 
 
    text-align: center; 
 
} 
 

 
.Home-section span { 
 
    color: deepskyblue; 
 
} 
 

 
.About-section { 
 
    background-color: black; 
 
    clear: inherit; 
 
} 
 

 
.Home-section { 
 
    background: url('https://images.unsplash.com/photo-1456428199391-a3b1cb5e93ab?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=db130336e8134fc3f734dbc4318f5c5e'); 
 
    background-size: cover; 
 
}
<!DOCTYPE html> 
 

 
<html> 
 

 
<head> 
 
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> 
 
    <link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.blue-cyan.min.css" /> 
 
    <script defer src="https://code.getmdl.io/1.1.3/material.min.js"></script> 
 
    <link rel="stylesheet" href="main.css"> 
 
    
 
    <style> 
 
    #view-source { 
 
     position: fixed; 
 
     display: block; 
 
     right: 0; 
 
     bottom: 0; 
 
     margin-right: 40px; 
 
     margin-bottom: 40px; 
 
     z-index: 900; 
 
    } 
 
    </style> 
 
</head> 
 
    
 
<body> 
 
    <div class="demo-layout-transparent mdl-layout mdl-js-layout" id="header"> 
 
     <header class="mdl-layout__header mdl-layout__header--waterfall"> 
 
     <div class="mdl-layout__header-row"> 
 
      <!-- Title --> 
 
      <span class="mdl-layout-title">Design Ambition</span> 
 
      <!-- Add spacer, to align navigation to the right --> 
 
      <div class="mdl-layout-spacer"></div> 
 
      <!-- Navigation --> 
 
      <nav class="mdl-navigation"> 
 
      <a class="mdl-navigation__link" href="">Home</a> 
 
      <a class="mdl-navigation__link" href="">About</a> 
 
      <a class="mdl-navigation__link" href="">Portfolio</a> 
 
      <a class="mdl-navigation__link" href="">Contact</a> 
 
      </nav> 
 
     </div> 
 
     </header> 
 

 
     <div class="mdl-layout__drawer mdl-layout--small-screen-only"> 
 

 
     <span class="mdl-layout-title">Design <br/> Ambition`</span> 
 
     <nav class="mdl-navigation"> 
 
      <a class="mdl-navigation__link" href="">Home</a> 
 
      <a class="mdl-navigation__link" href="">About</a> 
 
      <a class="mdl-navigation__link" href="">Portfolio</a> 
 
      <a class="mdl-navigation__link" href="">Contact</a> 
 
     </nav> 
 
     </div> 
 
     <main class="mdl-layout__content"> 
 
      <div class="page-content"> 
 
       <div class="Home-section"><h1>WE Create <span>DESIGNS</span> <br/> and People Just <br/>.........<br/><span>ADMIRE</span></h1></div> 
 
       <div class="About-section"><h1>ABOUT</h1></div> 
 
      </div> 
 
     </main> 
 
</div> 
 
    
 
</body> 
 
</html>

ありがとう:以下のコードを参照してください。

答えて

1

.Home-sectionにはh1タグがあり、.About-sectionには24pxの両方の垂直マージンがあります。これによって間隔が生じています。

Here is a very concise explanation by @Guffaなぜこの間隔が表示されますか?

demo-layout-transparent .mdl-layout__header, 
 
.demo-layout-transparent .mdl-layout__drawer-button { 
 
    color: white; 
 
} 
 

 
.mdl-layout-title { 
 
    font-family: 'League Spartan'; 
 
    font-size: 2em; 
 
    margin-top: 5px; 
 
} 
 

 
.Home-section h1{ 
 
    color: floralwhite; 
 
    font-family: 'League Spartan'; 
 
    text-align: center; 
 
} 
 

 
.Home-section span { 
 
    color: deepskyblue; 
 
} 
 

 
.About-section { 
 
    background-color: black; 
 
    clear: inherit; 
 
} 
 

 
.Home-section { 
 
    background: url('https://images.unsplash.com/photo-1456428199391-a3b1cb5e93ab?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=db130336e8134fc3f734dbc4318f5c5e'); 
 
    background-size: cover; 
 
} 
 

 
h1 { 
 
    margin: 0 !important; 
 
}
<!DOCTYPE html> 
 

 
<html> 
 

 
<head> 
 
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> 
 
    <link rel="stylesheet" href="https://code.getmdl.io/1.1.3/material.blue-cyan.min.css" /> 
 
    <script defer src="https://code.getmdl.io/1.1.3/material.min.js"></script> 
 
    <link rel="stylesheet" href="main.css"> 
 
    
 
    <style> 
 
    #view-source { 
 
     position: fixed; 
 
     display: block; 
 
     right: 0; 
 
     bottom: 0; 
 
     margin-right: 40px; 
 
     margin-bottom: 40px; 
 
     z-index: 900; 
 
    } 
 
    </style> 
 
</head> 
 
    
 
<body> 
 
    <div class="demo-layout-transparent mdl-layout mdl-js-layout" id="header"> 
 
     <header class="mdl-layout__header mdl-layout__header--waterfall"> 
 
     <div class="mdl-layout__header-row"> 
 
      <!-- Title --> 
 
      <span class="mdl-layout-title">Design Ambition</span> 
 
      <!-- Add spacer, to align navigation to the right --> 
 
      <div class="mdl-layout-spacer"></div> 
 
      <!-- Navigation --> 
 
      <nav class="mdl-navigation"> 
 
      <a class="mdl-navigation__link" href="">Home</a> 
 
      <a class="mdl-navigation__link" href="">About</a> 
 
      <a class="mdl-navigation__link" href="">Portfolio</a> 
 
      <a class="mdl-navigation__link" href="">Contact</a> 
 
      </nav> 
 
     </div> 
 
     </header> 
 

 
     <div class="mdl-layout__drawer mdl-layout--small-screen-only"> 
 

 
     <span class="mdl-layout-title">Design <br/> Ambition`</span> 
 
     <nav class="mdl-navigation"> 
 
      <a class="mdl-navigation__link" href="">Home</a> 
 
      <a class="mdl-navigation__link" href="">About</a> 
 
      <a class="mdl-navigation__link" href="">Portfolio</a> 
 
      <a class="mdl-navigation__link" href="">Contact</a> 
 
     </nav> 
 
     </div> 
 
     <main class="mdl-layout__content"> 
 
      <div class="page-content"> 
 
       <div class="Home-section"><h1>WE Create <span>DESIGNS</span> <br/> and People Just <br/>.........<br/><span>ADMIRE</span></h1></div> 
 
       <div class="About-section"><h1>ABOUT</h1></div> 
 
      </div> 
 
     </main> 
 
</div> 
 
    
 
</body> 
 
</html>

+0

感謝。つまり、結果を得るには、h1のマージンを0にするだけです。そして、h1が24pxのマージンを得る方法は? – pulkit

0

これを試してください:あなたの助けを

h1 { 
    font-size: 56px; 
    line-height: 1.35; 
    letter-spacing: -.02em; 
    margin: 0px 0; 
} 
関連する問題