2012-05-05 40 views
0

我想将一系列图像用作页面边框,而我的表格是矩形的。每张图片都是10px×10px。我有顶部,底部,侧面和角落的图像。除了侧面图像以外,所有图像均正常工作,%变量不起作用。 ls是左侧,我也有rs,右侧,我的顶部底部和角落图片工作正常。这是我的一小段代码片段:在CSS中指定图像高度px /%(级联样式表)

我的ASP页面代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "w3.org/TR/html4/strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
<head runat="server"> 
<title>Home Page</title> 
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" /> 
<asp:ContentPlaceHolder ID="HeadContent" runat="server"> 
</asp:ContentPlaceHolder> 
</head> 
<body> 
<div class="container"> 
<!-- Page Table Set Format --> 
<table cellpadding="0" cellspacing="0" class="MainTable"> 
<tr> 
<td class="LeftPageIndent" rowspan="5"> 
</td> 
<td class="HeadSpace" colspan="3"> 
</td> 
<td class="RightPageIndent" rowspan="5"> 
</td> 
</tr> 
<tr> 
<td class="tlc"> 
<img src="Images/tlc.jpg" alt="top left corner" /> 
</td> 
<td class="tp"> 
<img src="Images/tp.jpg" alt="top" class="BorderTop" /> 
</td> 
<td class="trc"> 
<img src="Images/trc.jpg" alt="top right corner" /> 
</td> 
</tr> 
<tr> 
<td> 
<img src="Images/ls.jpg" alt="left side" class="LSideBdrImage" /> 
</td> 
<td class="pageContent"> 
<!-- Page Form inside Main Content START --> 
<form id="Form1" runat="server"> 
<table class="ContentTable" cellspacing="0" cellpadding="0" width="100%" border="0"> 
<tr> 
<td> 
<p align="center"> 
<img src="Images/Logo.jpg" alt="Logo" width="341" height="63" border="0" /></p> 
</td> 
</tr> 
<tr> 
<td> 
<hr class="hrPageSeperator" color="#FF9900" /> 
</td> 
</tr> 
<tr> 
<td> 
<div class="page"> 
<div class="main"> 
<asp:ContentPlaceHolder ID="MainContent" runat="server" /> 
</div> 
</div> 
</td> 
</tr> 
<tr> 
<td> 
<hr class="hrPageSeperator" color="#FF9900" /> 
<div class="clear hideSkiplink"> 
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" 
           IncludeStyleBlock="false" Orientation="Horizontal"> 
<Items> 
<asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home" /> 
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About" /> 
</Items> 
</asp:Menu> 
</div> 
<hr class="hrPageSeperator" color="#FF9900" /> 
</td> 
</tr> 
</table> 
</form> 
<!-- Page Form inside Main Content END --> 
</td> 
<td> 
<img src="Images/rs.jpg" alt="right side" class="RSideBdrImage" /> 
</td> 
</tr> 
<tr> 
<td class="blc"> 
<img src="Images/blc.jpg" alt="bottom left corner" /> 
</td> 
<td class="btm"> 
<img src="Images/btm.jpg" alt="bottom" class="BorderBottom" /> 
</td> 
<td class="brc"> 
<img src="Images/brc.jpg" alt="bottom right corner" /> 
</td> 
</tr> 
<tr> 
<td class="FootSpace" colspan="3"> 
</td> 
</tr> 
</table> 
<!-- Page Table Set Format --> 
</div> 
</body> 
</html> 

我的CSS代码:

/* DEFAULTS 
----------------------------------------------------------*/ 

body 
{ 
background: #000000; 
font-size: .80em; 
font-family: "Helvetica Neue" , "Lucida Grande" , "Segoe UI" , Arial, Helvetica, Verdana, sans-serif; 
margin: 0px; 
padding: 0px; 
color: #696969; 
height: 100%; 
} 

#container 
{ 
min-height: 100%; 
} 

* html #container 
{ 
height: 100%; 
} 

a:link, a:visited 
{ 
color: #034af3; 
} 

a:hover 
{ 
color: #1d60ff; 
text-decoration: none; 
} 

a:active 
{ 
color: #034af3; 
} 

p 
{ 
margin-bottom: 10px; 
line-height: 1.6em; 
} 

/* Page Border Setup... 
----------------------------------------------------------*/ 
.MainTable 
{ 
width:100%; 
height:100%; 
} 

.HeadSpace 
{ 
height:4px; 
} 

.LeftPageIndent 
{ 
width: 12%; 
} 

.tlc 
{ 
width:10px; 
height:10px; 
border:0px; 
} 

.tp 
{ 
height:10px; 
border:0px; 
}  

.trc 
{ 
width:10px; 
height:10px; 
border:0px; 
} 

.ContentTable 
{ 
width:100%; 
height:100%; 
border:0px; 
} 

.blc 
{ 
width:10px; 
height:10px; 
border:0px; 
} 

.btm 
{ 
height:10px; 
border:0px; 
} 

.brc 
{ 
width:10px; 
height:10px; 
border:0px; 
} 

.RightPageIndent 
{ 
width: 12%; 
} 

.FootSpace 
{ 
height:2px; 
} 


/* Boarder Image Setup... 
-----------------------------------------------*/ 

.BorderTop 
{ 
width: 100%; 
height: 10px; 
border: "0"; 
} 

.LSideBdrImage 
{ 
width: 10px; 
height: 100%; 
border: "0"; 
} 

.RSideBdrImage 
{ 
width: 10px; 
height: 100%; 
border: "0"; 
} 

.BorderBottom 
{ 
width: 100%; 
height: 10px; 
border: "0"; 
} 


/* HEADINGS 
----------------------------------------------------------*/ 

.hrPageSeperator 
{ 
color:#FF9900; 
} 

h1, h2, h3, h4, h5, h6 
{ 
font-size: 1.5em; 
color: #666666; 
font-variant: small-caps; 
text-transform: none; 
font-weight: 200; 
margin-bottom: 0px; 
} 

h1 
{ 
font-size: 1.6em; 
padding-bottom: 0px; 
margin-bottom: 0px; 
} 

/* PRIMARY LAYOUT ELEMENTS 
----------------------------------------------------------*/ 

.page 
{ 
width: 100%; 
background-color: #000000; 
margin: 1px auto 0px auto; /* border: 1px solid #496077; */ 
} 

.main 
{ 
padding: 0px 12px; 
margin: 12px 8px 8px 0px; 
min-height: 100%; 
width: 100%; 
} 

我的问题是,我可以设置在像素图像高度,但我不能以%为单位设置图像高度。我研究了这一点,并且有很多信息,但还不足以以我的方式看到错误。有人可以帮助我,我会非常appreaciate它。

在此先感谢。

Chris

P.S.每张图片保持10px10px不变。

回答

0

MyGuruG是在正确的轨道上,这里是我必须做的:

ASP代码:

<!doctype HTML public "-//W3C//DTD HTML 4.0 Transitional//EN" > 
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "w3.org/TR/html4/strict.dtd"> --> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
<head runat="server"> 
<title>Home</title> 
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" /> 
<asp:ContentPlaceHolder ID="HeadContent" runat="server"> 
</asp:ContentPlaceHolder> 
</head> 
<body> 
<!-- Set Page Format Table - START --> 
<asp:Table CssClass="MainTable" runat="server" CellPadding="0" CellSpacing="0"> 
<asp:TableRow CssClass="HeadSpace"> 
<asp:TableCell ColumnSpan="6"> 
</asp:TableCell> 
</asp:TableRow> 
<asp:TableRow> 
<asp:TableCell RowSpan="3"> 
<asp:Image ImageUrl="Images/Border/indent.jpg" runat="server" CssClass="LeftPageIndent" AlternateText="Border Indent" /> 
</asp:TableCell> 
<asp:TableCell> 
<asp:Image ImageUrl="Images/Border/tlc.jpg" runat="server" AlternateText="Top Left Border Corner" Width="10px" Height="10px" /> 
</asp:TableCell> 
<asp:TableCell ColumnSpan="2"> 
<asp:Image ImageUrl="Images/Border/tp.jpg" runat="server" AlternateText="Top Border" CssClass="BorderTop"/> 
</asp:TableCell> 
<asp:TableCell> 
<asp:Image ImageUrl="Images/Border/trc.jpg" runat="server" AlternateText="Top Right Border Corner" Width="10px" Height="10px" /> 
</asp:TableCell> 
<asp:TableCell RowSpan="3"> 
<asp:Image ID="Image1" ImageUrl="Images/Border/indent.jpg" runat="server" CssClass="RightPageIndent" AlternateText="Border Indent" /> 
</asp:TableCell> 
</asp:TableRow> 
<asp:TableRow> 
<asp:TableCell> 
<asp:Image ImageUrl="Images/Border/ls.jpg" runat="server" AlternateText="Left Border Side" Height="100%" Width="10" /> 
</asp:TableCell> 
<asp:TableCell ColumnSpan="2"> 
<form id="Form1" runat="server"> 
<div class="page"> 
<p align="center"> 
<img src="Images/Border/logo.jpg" alt="Logo" border="0" /></p> 
<div class="main"> 
<asp:ContentPlaceHolder ID="MainContent" runat="server" /> 
</div> 
<p class="FootSpaceText">Copyright © All Rights Reserved</p> 
</div> 
</form> 
</asp:TableCell> 
<asp:TableCell> 
<asp:Image ImageUrl="Images/Border/rs.jpg" runat="server" AlternateText="Right Border Side" Height="100%" Width="10" /> 
</asp:TableCell> 
</asp:TableRow> 
<asp:TableRow> 
<asp:TableCell CssClass="blc"> 
<asp:Image ImageUrl="Images/Border/blc.jpg" runat="server" AlternateText="Bottom Left Border Corner" /> 
</asp:TableCell> 
<asp:TableCell CssClass="btm" ColumnSpan="2"> 
<asp:Image ImageUrl="Images/Border/btm.jpg" runat="server" AlternateText="Bottom Border" Width="100%" Height="10px" /> 
</asp:TableCell> 
<asp:TableCell CssClass="brc"> 
<asp:Image ImageUrl="Images/Border/brc.jpg" runat="server" AlternateText="Bottom Right Border Corner" Width="10px" Height="10px" /> 
</asp:TableCell> 
</asp:TableRow> 
<asp:TableRow CssClass="FootSpace"> 
<asp:TableCell ColumnSpan="6"> 
</asp:TableCell> 
</asp:TableRow> 
</asp:Table> 
<!-- Set Page Format Table - END --> 
</body> 
</html> 

我的CSS代码:

/* DEFAULTS 
----------------------------------------------------------*/ 

body 
{ 
background: #000000; 
font-size: .80em; 
font-family: "Helvetica Neue" , "Lucida Grande" , "Segoe UI" , Arial, Helvetica, Verdana, sans-serif; 
margin: 0px; 
padding: 0px; 
color: #696969; 
} 

a:link, a:visited 
{ 
color: #034af3; 
} 

a:hover 
{ 
color: #1d60ff; 
text-decoration: none; 
} 

a:active 
{ 
color: #034af3; 
} 

.FootSpaceText 
{ 
text-align: center; 
} 

/* Page Border Setup... 
----------------------------------------------------------*/ 

.MainTable 
{ 
width:100%; 
height:100%; 
} 

.HeadSpace 
{ 
height: 17px; 
} 

.LeftPageIndent 
{ 
width: 140; 
} 

.RightPageIndent 
{ 
width: 140; 
} 

.tlc 
{ 
width: 10px; 
height: 10px; 
border: 0px; 
} 

.tp 
{ 
width: 100%; 
height: 10px; 
border: 0px; 
} 

.trc 
{ 
width: 10px; 
height: 10px; 
border: 0px; 
} 

.blc 
{ 
width: 10px; 
height: 10px; 
border: 0px; 
} 

.btm 
{ 
width: 100%; 
height: 10px; 
border: 0px; 
} 

.brc 
{ 
width: 10px; 
height: 10px; 
border: 0px; 
} 

.FootSpace 
{ 
height: 17px; 
} 


/* Boarder Image Setup... 
-----------------------------------------------*/ 

.BorderTop 
{ 
width: 100%; 
height: 10; 
border: 0; 
} 

LSideBdrImage 
{ 
width: 10; 
height: 100%; 
} 

RSideBdrImage 
{ 
width: 10; 
height: 100%; 
} 

.BorderBottom 
{ 
width: 100%; 
height: 10; 
border: 0; 
} 


/* HEADINGS 
----------------------------------------------------------*/ 

p 
{ 
margin-bottom: 10px; 
line-height: 1.6em; 
} 

h1, h2, h3, h4, h5, h6 
{ 
font-size: 1.5em; 
color: #666666; 
font-variant: small-caps; 
text-transform: none; 
font-weight: 200; 
margin-bottom: 0px; 
} 

h1 
{ 
/*-- Page Header Heading --*/ 
font-size: x-large; 
padding-bottom: 0px; 
margin-bottom: 0px; 
color: #CCFF33; 
} 

h2 
{ 
/*-- Page Header Heading 2 --*/ 
font-weight: bold; 
color: #FF9900; 
} 

h3 
{ 
/*-- Bold Red Serious Text --*/ 
font-weight: bold; 
color: Red; 
} 

h4 
{ 
/*-- Page Sub-Heading --*/ 
font-size: 1em; 
padding-top: 1px; 
padding-bottom: 1px; 
margin-bottom: 0px; 
font-variant: normal; 
color: #FF9900; 
} 

h5 
{ 
/*-- Page Heading 3 --*/ 
font-size: 2.2em; 
font-weight: bold; 
color: #FF9900; 
} 

/* PRIMARY PAGE CONTENT LAYOUT ELEMENTS 
----------------------------------------------------------*/ 

.page 
{ 
width: 100%; 
background-color: #000000; 
margin: 1px auto 0px auto; 
} 

.main 
{ 
padding: 0px 12px; 
margin: 12px 8px 8px 0px; 
min-height: 100%; 
width: 100%; 
} 

/* PRIMARY PAGE CONTENT TABLES 
----------------------------------------------------------*/ 

.MainContent 
{ 
width:100%; 
} 

.CellBorder 
{ 
/* -- border:1px solid #333333; --*/ 
border-bottom-style: solid; 
border-bottom-width: 1px; 
border-bottom-color: #333333; 
border-left-style: solid; 
border-left-width: 1px; 
border-left-color: #333333; 
border-right-style: solid; 
border-right-width: 1px; 
border-right-color: #333333; 
border-top-style: solid; 
border-top-width: 1px; 
border-top-color: #333333; 
} 

,使这项工作守则如下。

第一:

<!doctype HTML public "-//W3C//DTD HTML 4.0 Transitional//EN" > 

我哑然创立这个。也许有人可以解释为什么需要更改“文档类型”?毫无疑问,所有页面都有一套标准的基本要求,高度会是其中的一部分吗?

二:

<asp:Table CssClass="MainTable" runat="server" CellPadding="0" CellSpacing="0"> 
<!-- Table Content Here --> 
</asp:Table> 

我尝试了标准的HTML表,但这并没有为我工作,所以我只好用ASP:表标签来代替。

三:

.MainTable 
{ 
width:100%; 
height:100%; 
} 

的ASP:表需要有它的高度和宽度设置,或这不会工作。

四:

<asp:Image ImageUrl="Images/Border/ls.jpg" runat="server" AlternateText="Left Border Side" Height="100%" Width="10" /> 

我必须设置在ASP的高度和宽度:图像标签。在CSS中设置高度和宽度不适用于我。

此外,我不得不用一个变通设置表缩进:

<asp:TableCell RowSpan="3"> 
<asp:Image ID="Image1" ImageUrl="Images/Border/indent.jpg" runat="server" CssClass="RightPageIndent" AlternateText="Border Indent" /> 
</asp:TableCell> 

我设置的ASP:TableCell的Width属性,但只有左侧的工作。右侧根本行不通。

我认为这就是所有,这是一个真正的痛苦,你知道什么才能达到这个愚蠢的问题的底部。我不相信做这个简单的任务非常困难。我必须将这个答案给MyGuruG,因为这真的是基本的总体问题谢谢MyGuruG。

0

HTML通常使用整个身体的现有高度来调整身体内的元素的大小。所以,即使您的桌子高度和图像设置为100%,这100%也会受到您身体尺寸的限制。

要解决此问题,请尝试将身高设置为100%。

+0

嗨,我的古茹吉,试过了,它没有做任何改变。 –

+0

嗨, 确保以下内容 您的HTML元素类型设置为 <!DOCTYPE HTML PUBLIC“ - // W3C // DTD HTML 4.01 // EN”“http://www.w3.org/TR/html4/strict .dtd“> html,body { height:100%; } #容器{ 最小高度:100%; } * html #container { height:100%; }

MyGuruG

+0

对不起,仍然没有工作纪 –