我正在使用CSS重置脚本,导致图像无法居中。有谁知道我该如何解决?

的HTML

    <head>
        <link rel="stylesheet" type="text/css" href="css/css_reset.css" />
        <link rel="stylesheet" type="text/css" href="css/mystyles.css" />
    </head>

    <body>
        <img src="images/final2.gif" class="stretch" alt="" />
        <p>This is the first paragraph in the body of your new HTML file!</p>
            asdfas
    </body>


的CSS

body {
    /*width: 100%;
    height: 100%;
    position: fixed;
    left: 0px;
    top: 0px; */
    z-index: -1; /* Ensure div tag stays behind content; -999 might work, too. */

    background-color:black;
}

.stretch {
    /*width:100%;
    height:100%;*/
    z-index:-1;
    position:fixed;
    margin-left:auto;
    margin-right:auto;
}


CSS重置

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;
}

最佳答案

好..

使用这个CSS

.stretch {

    z-index:-1;
    display:block;
    margin-left:auto;
    margin-right:auto;
}


检查此演示。http://jsfiddle.net/hzZXV/1/

07-24 17:39