简体   繁体   中英

HTML CSS style height:100% Works fine in chrome but not in IE or Firefox [becoming crazy!]

i have an index page that navigates via opening the url inside a div

In chrome works fine but not with any other browser.

the code is the following:

<!-- This is a part of index.php who redirects the browser to another site inside a div.-->

   <div  style="width:100%; height:100%; overflow:hidden;">
    <object type="text/html" data="http://*****.com/home.php" style="width:100%; height:100%; margin:1%;">
    </object>
</div>

How can i solve it, what am i doing wrong!?

add this at the begining of your css it will reset the default parameter of the browser like margin on main elements :

/* CSS reset */
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;
}

Height is relative to the parent, so you need to add height:100% to body and html to get it to work. Not sure why it works in Chrome...

In you header.css you want to declare:

html, body { height: 100% }

on line 7 of it you just put the width

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM