Css h1在divs中的定位问题

Css h1在divs中的定位问题,css,html,positioning,Css,Html,Positioning,我正试着把h1定位在DIV内。具体地说,我试图使它们水平和垂直居中,但我在这样做时遇到了一些问题。我的代码粘贴在下面。任何帮助都将不胜感激 HTML CSS 2(迈耶重置) 这里有一个解决方案: h1 { text-align: center; position: relative; top: 200px; <- made change } h1{ 文本对齐:居中; 位置:相对位置; top:200px;太多代码了!你能把它归结为一个,或者发布一个吗

我正试着把h1定位在DIV内。具体地说,我试图使它们水平和垂直居中,但我在这样做时遇到了一些问题。我的代码粘贴在下面。任何帮助都将不胜感激

HTML

CSS 2(迈耶重置)

这里有一个解决方案:

h1 {
    text-align: center;
    position: relative;
    top: 200px;        <- made change
}
h1{
文本对齐:居中;
位置:相对位置;

top:200px;太多代码了!你能把它归结为一个,或者发布一个吗?当然!这里是小提琴:对不起,长度太长了!
  body {
    font-family: 'Inconsolata', sans-serif;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 5px;

}

header{
    top: 0px;
    width: 100%;
    height: 40px;
    background-color: black;
    position: fixed;
}

header li {
    margin-right: 20px;
    margin-top: 10px;
}

li {
    color: white;
    list-style-type: none;
    display: inline-block;
}

ol {
    text-align: center;
}

#A {
    text-decoration: underline;
}

h1 {
    text-align: center;
    position: relative;
    margin-top: 200px;
}

div {
    height: 350px;
    width: 100%;
}

#teal1 {
    background: #1CF9D4;
}

#teal2 {
    background: #1DE4DB;
}

#teal3 {
    background: #1FD0E2;
}

#blue1 {
    background: #20BBE9;
}

#blue2 {
    background: #22A7F0;
}

#blue3 {
    background: #2392F7;
}

#purple1 {
    background: #4F87DC;
}

#purple2 {
    background: #727EC7;
}

#red1 {
    background: #DC6387;
}
/* 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%;
    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;
}


    header li {
        margin-right: 20px;
        margin-top: 10px;
    }

    li {
        color: white;
        list-style-type: none;
        display: inline-block;
    }

    ol {
        text-align: center;
    }

    #A {
        text-decoration: underline;
    }

    h1 {
        text-align: center;
        position: relative;
        margin-top: 200px;
    }

    div {
        height: 350px;
        width: 100%;
    }

    #teal1 {
        background: #1CF9D4;
    }

    #teal2 {
        background: #1DE4DB;
    }

    #teal3 {
        background: #1FD0E2;
    }

    #blue1 {
        background: #20BBE9;
    }

    #blue2 {
        background: #22A7F0;
    }

    #blue3 {
        background: #2392F7;
    }

    #purple1 {
        background: #4F87DC;
    }

    #purple2 {
        background: #727EC7;
    }

    #red1 {
        background: #DC6387;
    }
h1 {
    text-align: center;
    position: relative;
    top: 200px;        <- made change
}