[英]Background image fit on screen IE10
我正在嘗試在CSS中設置背景圖片以適合屏幕。 在最新版本的Chrome上運行正常,但是,IE 10出現了問題。
html {
border-top: 10px solid #8A85A5;
background: url("http://www.lifeintempe.com/gfx/photos/2008-11-28-tempe-sunset-56632.jpg") no-repeat center center fixed ;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
這就是在IE 10中的顯示方式。有太多空白...
關於如何解決此問題的任何建議?
我也嘗試添加...沒有用。
min-height:100%;
min-width: 100%;
更新:
以上是我在CSS文件中擁有的所有內容。 這是我的html
樣子:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="ScreenPop.Site" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel ="stylesheet" type ="text/css" href="Style/MyStyle.css" />
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
</form>
</body>
</html>
這為我工作:
html {
border-top: 10px solid #8A85A5;
background-color: #d5d5d5;
background-image: url('http://www.lifeintempe.com/gfx/photos/2008-11-28-tempe-sunset-56632.jpg');
background-repeat: no-repeat;
background-position: top center;
background-size: 100%;
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.lifeintempe.com/gfx/photos/2008-11-28-tempe-sunset-56632.jpg', sizingMethod='scale');
-ms-filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://www.lifeintempe.com/gfx/photos/2008-11-28-tempe-sunset-56632.jpg', sizingMethod='scale')";
}
解決方案2:
使用這樣的wrapper div
:
<div id="bg">
<img src="http://www.lifeintempe.com/gfx/photos/2008-11-28-tempe-sunset-56632.jpg" alt="">
</div>
#bg {
position: fixed;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
}
#bg img {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
min-width: 50%;
min-height: 50%;
}
更新
谷歌搜索了一下之后,發現它對我有用。 我已經測試過了 希望對你有效。
<body> <img src="http://www.lifeintempe.com/gfx/photos/2008-11-28-tempe-sunset-56632.jpg" alt="background image" id="bg" />
<form id="form1" runat="server">
<div id="wrapper">
</div>
</form>
</body>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
img#bg {
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.