CSS重置 - 设置重复规则

时间:2015-10-30 02:36:36

标签: html css

所以我有一个问题的解决方法,但出于学习目的,我想不知道为什么或如何做到这一点。我有一个CSS重置将身体边缘设置为0.我的页面没有边缘到边缘,在检查元素时我注意到身体有8px边距。然后,我设置了一个额外的规则,使身体边缘为0.这有效,但为什么我必须设置两次相同的规则?

<html>
<head>
    <title>New Coffee Site</title>

    <link rel="stylesheet" type="text/css" href="coffeestyles.css">

</head>
<body>
<div id = "back-container"> 
    <div id = "page-container">
        <header>    
            <img id = "logo" src = "coffelogo1.png">
            <nav>
                <a href="home.html"> Home </a>
                <a href="menu.html"> Menu </a>
                <a href="about.html"> About us </a>
                <a href="something.html"> Something </a>
            </nav>
        </header>
    </div>
</div>
</body>

<style type="text/css">


/* http://meyerweb.com/eric/tools/css/reset/
   v2.0 | 20110126
   License: none (public domain)
*/

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-size: 100%;
  font: inherit;
  vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
  display: block;
}
body {
  line-height: 1;
}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

*,
*:before,
*:after {
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
}

/* My CSS 
///////// */



body {
    margin: 0;
    }

    #back-container {
        width: 1214px;
        height: 809px;
        background-image: url("coffee-beans 2.jpg");

    }

    #page-container {
        width: 900px;
        height: 100%;
        background-color: rgba(214,214,214, .8);
        margin-left: auto;
        margin-right: auto;
    }

    header {
        width: auto;
        height: 130px;
        background-color: rgba(216, 160, 113, .5);
        border-bottom: 3px double 864C1B;
        font-family: "Trattatello";
    }

    #logo {
        margin-top: -75px;
    }

    nav {
        float: right;
        width:  550px;
        padding-top: 40px;
    }

    nav a {
        text-decoration: none;
        color: black;
        border-radius: 20px;
        border: 2px solid black;;
        background-color: 864C1B;
        padding-top: 15px;
        margin-right: 20px;
        display: inline-block;
        text-align: center;
        width: 100px;
        height: 45px;
    }

    #article1 {
        padding-top: 30px;
        margin-right: 100px;
        margin-left: 100px;
        border-left: 3px double 864C1B;
        border-right: 3px double 864C1B;
        padding-left: 25px;
        padding-right: 25px;
        height: 100%;
        font-size: 30px;
        font-family: sans-serif;
        background-color: rgba(216, 160, 113, .5);
    }



</style>

0 个答案:

没有答案