日期:2014-05-18 浏览次数:20681 次
<html>
<head>
<title></title>
<style>
*{margin:0;padding:0;}
.bodys
{
width:100%; height:900px; border:1px solid red;
}
</style>
</head>
<body>
<div class="bodys">
</div>
</body>
</html>
------解决方案--------------------
<html>
<head>
<title></title>
<style>
*{margin:0;padding:0;}
.bodys
{
width:100%; height:900px; border:1px solid red;
}
</style>
</head>
<body>
<div class="bodys">
</div>
</body>
</html>
------解决方案--------------------
<style type="text/css">
body
{
background-image:url(<%=backgroundImage%>);
}
</style>
using System.Web.UI.HtmlControls;
protected override void OnInit(EventArgs e)
{
// Define an Literal control.
HtmlGenericControl css = new HtmlGenericControl();
css.TagName = "style";
css.Attributes.Add("type", "text/css");
string imageURL = string.Empty;
//Logic to determin imageURL goes here
//Update Tag
css.InnerHtml = @"body{background-image: url(" + imageURL + ");}";
// Add the Tag to the Head section of the page.
Page.Header.Controls.Add(css);
base.OnInit(e); }
public string backgroundImage = "defaultImage.png";
或者:
<body style="background-image:url(bgr.jpg);">
...
</body>
------解决方案--------------------
<html>
<head>
<title></title>
<style>
*{margin:0;padding:0;}
.bodys
{
width:100%; height:900px; border:1px solid red;background-image:url(bgr.jpg);
}
</style>
</head>
<body>
<div class="bodys">
</div>
</body>
</html>