我有一个正在开发的网站,它使用图像作为整个网站的背景。在 FF 和 Safari 中运行良好。但是 IE 有一些麻烦。有时它根本不加载图像,有时它被部分加载,有时它在一两秒后加载。
除此之外,据说我发现的 IE 证明黑客并不是那么 IE 证明。关于如何在纯 CSS 中使用图像作为网站的完整背景的任何想法?
我已经将 html/css 剥离到可能的相关部分;完整的例子在http://www.topografieindeklas.nl/home
的HTML
<body>
<div id="header">
<div id="headerWrap" class="alignCenter">
<p>Topografie</p>
</div><!-- end headerWrap -->
</div><!-- end header -->
<div id="menu">
<div id="menuWrap" class="alignCenter">
<ul>
<li>Item 1</li>
<li>Item 2</li
</ul>
</div><!-- end menuWrap -->
</div><!--- end menu -->
<div id="page">
<div class="pageBrandingWrap">
<div class="pageBranding alignCenter">
<h1>Title</h1>
</div>
</div><!-- End pageBrandingWrap -->
<div class="entrytextWrap">
<div class="entrytext alignCenter">
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
</div>
</div><!-- End entrytextWrap -->
</div><!-- end page -->
<div class="clear"></div>
<div id="footer">
<div id="footerWrap" class="alignCenter">
</div><!-- end footerWrap -->
</div>
</body>
</html>
CSS
/* Correct/normalize default browser styles */
@import url('style/normalize.css');
/* Import the open sans font */
@import url(http://fonts.googleapis.com/css? family=Open+Sans:300italic,400italic,600italic,400,300,700,800,600);
*{
margin:0px;
padding:0px;
}
html{
min-height: 100%;
background-size: cover;
background-image: url(style/img/masterBG.jpg);
background-repeat: no-repeat;
background-position: right bottom;
background-attachment:fixed;
}
body{
min-height:100%;/*Corrects the full image background*/
font-family:Arial, Helvetica, sans-serif;;
font-size:14px;
text-align: center;
}
#header, #branding, #menu, #page, #footer{
width:100%;
}
#header{
margin:20px 0 0 0;
background: rgb(255, 255, 255) transparent;/* Fallback for web browsers that doesn't support RGBa */
background: rgba(255, 255, 255, 0.75);/* RGBa with 0.6 opacity, for non-stupid browsers */
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#BFFFFFFF, endColorstr=#BFFFFFFF);/* For IE 5.5 - 7*/
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#BFFFFFFF, endColorstr=#BFFFFFFF)";/* For IE 8*/
}
#headerWrap, #brandingWrap, #menuWrap{
width:900px;
font-family: 'Open Sans', sans-serif;
}