小问题难道我啊!这个图始终就是不居中?高手!纯前台!

tys101582 2010-01-09 11:20:51
框架调用的default.aspx
框架如下:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>

</head>


<frameset framespacing="1" border="0" frameborder="0" rows="70,*,25">
<form id="form1" runat="server">
<frame name="top" scrolling="no" noresize="noresize" target="contents" src="top.aspx" marginheight="4">
<frameset cols="140,8,*" name="main_m">
<frame name="left" src="left.aspx?power=<%=power%>" scrolling="auto" noresize="noresize" target="main" >
<frame name="cen" src="default.aspx" marginwidth="0" marginheight="0" scrolling="auto" noresize="noresize" style="padding: 0px">
<frame name="main" src="index_left.aspx" marginwidth="0" marginheight="0" scrolling="auto" noresize="noresize" style="padding: 0px">
</frameset>
<frame name="bottom" scrolling="no" noresize="noresize" src="boot.aspx" style=" vertical-align:top" marginheight="2">
<noframes>
<body>
<p>此网页使用了框架,但您的浏览器不支持框架。</p>

</body>
</noframes>
</form>
</frameset>


文件名:default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>


<script language="JavaScript" type="text/javascript">
<!--
function changeState()
{
if(parent.document.getElementById('main_m').cols!="140,8,*")
{
parent.document.getElementById('main_m').cols="140,8,*";
parent.document.getElementById('left').style.display="";
image1Id.src = "../images/left.gif";
}
else
{
parent.document.getElementById('main_m').cols = "0,8,*";
parent.document.getElementById('left').style.display="none";
image1Id.src = "../images/right.gif";

}
}

//-->
</script>

</head>
<body style="background-color:Blue;" >
<form id="form1" runat="server">
<div>
<table height="100%" cellspacing="0" cellpadding="0" border="0" >
<tbody>
<tr >
<td height="100%" style="width: 9px; vertical-align: middle; text-align: center;" >

<img id="image1Id" src="images/left.gif" onclick="changeState();" alt="关闭/打开左栏" border="0" />

</td>
</tr>
</tbody>
</table>
</div>
</form>
</body>
</html>


就是里面那个<img id="image1Id" src="images/left.gif" onclick="changeState();" alt="关闭/打开左栏" border="0" />死活不垂直居中,在页面里看是正常的居中了,可是运行起来还是不居中.图片有时还不变?郁闷啊!

光前台代码,无后台的!谢谢!是不是和IE有关系?
...全文
211 26 打赏 收藏 转发到动态 举报
写回复
用AI写文章
26 条回复
切换为时间正序
请发表友善的回复…
发表回复
tys101582 2010-01-11
  • 打赏
  • 举报
回复
孟老大,分结早了,不好意思啊!
<style>
html,body,form,table,div{height:100%;margin:0;padding:0}
</style>
用这个出现下拉条.也不显示出来,去掉那个就可以正常显示.还请老大指点!
段传涛 2010-01-09
  • 打赏
  • 举报
回复
比我来的早,你把楼上几位 说的试试 应该可以了
Jeremiah 2010-01-09
  • 打赏
  • 举报
回复
align="center"

<div>
<table height="100%" cellspacing="0" cellpadding="0" border="0" align="center">
<tbody>
<tr>
<td height="100%" style="width: 9px; vertical-align: middle; text-align: center;" >

<img id="image1Id" src="images/left.gif" onclick="changeState();" alt="关闭/打开左栏" border="0" />

</td>
</tr>
</tbody>
</table>
</div>
qibao33 2010-01-09
  • 打赏
  • 举报
回复
帮顶
HarveyYan 2010-01-09
  • 打赏
  • 举报
回复
<td height="100%" style="width: 9px; height:100%; line-height:100%; vertical-align: middle; text-align: center;" >

<img id="image1Id" src="images/left.gif" onclick="changeState();" alt="关闭/打开左栏" border="0" />

</td>
happyboyxq1985 2010-01-09
  • 打赏
  • 举报
回复
把框架里的default.aspx页面的style效果调到居中试试。
lovexilove 2010-01-09
  • 打赏
  • 举报
回复
看是没什么问题 帮顶
koukoujiayi 2010-01-09
  • 打赏
  • 举报
回复
或者
<center>
<img id="image1Id" src="images/left.gif" onclick="changeState();" alt="关闭/打开左栏" border="0" />
</center>
koukoujiayi 2010-01-09
  • 打赏
  • 举报
回复
加<center>试试

<center>
<table height="100%" cellspacing="0" cellpadding="0" border="0" >
.......

</table>
<center>

ninja 2010-01-09
  • 打赏
  • 举报
回复
[Quote=引用 24 楼 net_lover 的回复:]
什么不行啊???
要不显示滚动条这样就可以

    <style>
    html,body,form,table,div{height:100%;margin:0;padding:0}
    </style>


删除
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
是不合理的

不学会使用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
你以后会很麻烦的


[/Quote]


孟老大说得太对了,不要只看眼前利益,方法有很多的,这样也行
<title>Untitled Page</title>
<style>
html,body,form,table,div{height:100%; overflow-y:hidden;}
</style>
孟子E章 2010-01-09
  • 打赏
  • 举报
回复
什么不行啊???
要不显示滚动条这样就可以

<style>
html,body,form,table,div{height:100%;margin:0;padding:0}
</style>


删除
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
是不合理的

不学会使用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
你以后会很麻烦的

wartim 2010-01-09
  • 打赏
  • 举报
回复
form1.image1Id.src=...
tys101582 2010-01-09
  • 打赏
  • 举报
回复
提示我ID没定义:image1Id????????????
tys101582 2010-01-09
  • 打赏
  • 举报
回复
[Quote=引用 20 楼 wartim 的回复:]
LZ是IE8吧,

HTML code<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

把这句话注释掉你的烦恼就解除了
[/Quote]

wartim
我是IE6,为什么我每次点击全是这一个图呢?
wartim 2010-01-09
  • 打赏
  • 举报
回复
LZ是IE8吧,


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


把这句话注释掉你的烦恼就解除了
tys101582 2010-01-09
  • 打赏
  • 举报
回复
[Quote=引用 18 楼 sp1234 的回复:]
引用 15 楼 tys101582 的回复:
<style>
    html,body,form,table,div{height:100%}
    </style>

加上这个后,出现下拉条了


仅仅设置body,别的不应该。
[/Quote]


什么意思?

这样?:
<style>
body{height:100%}
</style>
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 tys101582 的回复:]
<style>
    html,body,form,table,div{height:100%}
    </style>

加上这个后,出现下拉条了
[/Quote]

仅仅设置body,别的不应该。
fenglei1985815 2010-01-09
  • 打赏
  • 举报
回复
那我只能将的必杀技告诉你了。


请重新启动计算机。
  • 打赏
  • 举报
回复
呵呵,xhtml有个“癖好”,你必须先为body设置高度为100%,然后才能控制里边的html对象垂直对齐规则。
tys101582 2010-01-09
  • 打赏
  • 举报
回复
<style>
html,body,form,table,div{height:100%}
</style>

加上这个后,出现下拉条了
加载更多回复(6)

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧