Material Design Lite div之间的空白区域

时间:2016-03-25 12:39:46

标签: html css material-design material-design-lite

我正在设计一个包含材料设计精简版的网站,我可以找出为什么页面内容中div之间存在空格。我正在为我的任何部分添加一个新div,它会在前面的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>
&#13;
&#13;
&#13;

提前感谢您的建议。

2 个答案:

答案 0 :(得分:1)

h1中有.Home-section个标记,.About-section中有另一个标记,两者的垂直边距均为24px。这导致间距。

@Guffa的

Here is a very concise explanation关于你看到这个间距的原因。

&#13;
&#13;
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;
}
&#13;
<!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>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

请试试这个:

h1 {
    font-size: 56px;
    line-height: 1.35;
    letter-spacing: -.02em;
    margin: 0px 0;
}