CSS定位的问题

jhdlzx 2009-04-21 05:14:58
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="daiban.aspx.cs" Inherits="daiban" Theme="moren" %>

<!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>
<style type="text/css">
<!--

#bt {
position : static;
width:800px;
height:50px;
z-index:1;
text-align :center;
font-size:14pt;
margin-left:auto;
margin-right:auto;
}
#lctb {
position : static;
width:800px;
height:250px;
z-index:2;
overflow: scroll;
border-right: #0099ff 1px solid;
border-top: #0099ff 1px solid;
border-left: #0099ff 1px solid;
border-bottom: #0099ff 1px solid;
margin-left:auto;
margin-right:auto;
}
-->
</style>
</head>
<body style="font-size:9pt;" >
<form id="form1" runat="server">
<div id="bt">
<br />
待   办   事   宜</div>

<div id="lctb">
<span style="color: #ff3333">
流入人员对方通报</span><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
<asp:GridView ID="gvlctb" runat="server" Width="774px" OnPageIndexChanging="gvlctb_PageIndexChanging" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="打开">
<ItemTemplate>
 <asp:LinkButton ID="lblctb" OnCommand="lblctb_Command" runat="server" CommandArgument='<%# Eval("bh") %>'
Text='<%# "打开" %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="tbrq" HeaderText="通报日期" />
<asp:BoundField DataField="dw1" HeaderText="通报单位" />
<asp:BoundField DataField="fnxm" HeaderText="妇女姓名" />
<asp:BoundField DataField="zfxm" HeaderText="丈夫姓名" />
<asp:BoundField DataField="bh" HeaderText="通报单编号" />
</Columns>
</asp:GridView>
</div>
</form>
</body>
</html>



上面的代码实现居中,第一次显示时实现了居中,但一旦打开其中链接后,就不居中了,请高手帮忙。
...全文
145 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
jhdlzx 2009-05-01
  • 打赏
  • 举报
回复
问题终于OK了,就是response.write的问题。非常感谢各位的大力支持帮助
huang_net 2009-04-30
  • 打赏
  • 举报
回复
response.write输出的问题
改用this.ClientScript.RegisterStartupScript(typeof(string),"js","你的js语句",true);
wangliang8229780 2009-04-30
  • 打赏
  • 举报
回复

.body{
text-align:center;margin:auto;
}
我姓区不姓区 2009-04-30
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 jhdlzx 的回复:]
11楼的朋友,我的打开链接是有response.write,我用它调用了javascript脚本,难道是它的问题
[/Quote]
那就是了,Response.Write是会破坏页面布局的,以后不要再用它输出脚本了
用:
this.ClientScript.RegisterStartupScript(typeof(string),"js","你的js语句",true);
jhdlzx 2009-04-30
  • 打赏
  • 举报
回复
11楼的朋友,我的打开链接是有response.write,我用它调用了javascript脚本,难道是它的问题
gdjlc 2009-04-30
  • 打赏
  • 举报
回复
应该是
#content {
margin: 0 auto;
}
gdjlc 2009-04-30
  • 打赏
  • 举报
回复
哦,上面写错了,
#bt {
margion: 0 auto;
}

改为
#content {
margion: 0 auto;
}

gdjlc 2009-04-30
  • 打赏
  • 举报
回复
再加一个外层的div:


#bt {
margion: 0 auto;
}



<div id="content">

<!--加上面-->
<div id="bt">
<br /> 待   办   事   宜
</div>
<div id="lctb">
......
</div>
<!--加下面-->

</div>
我姓区不姓区 2009-04-30
  • 打赏
  • 举报
回复
你是不是在“打开”链接的事件中有Response.Write啊?
lingdu_hua 2009-04-30
  • 打赏
  • 举报
回复
position : static;
这句没有用。去掉吧。
然后加
*{marging:0;padding:0;}
#bt,#lctb{margin:auto;}
alan0128 2009-04-30
  • 打赏
  • 举报
回复
margin: 0px auto; text-align :center;试试
nbgcqlk 2009-04-30
  • 打赏
  • 举报
回复
把这个去掉...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
要不就定义个样式
*{margin:auto;}试试
jhdlzx 2009-04-30
  • 打赏
  • 举报
回复
楼上的还是不行
步慢生错 2009-04-24
  • 打赏
  • 举报
回复
把css单独放一个地方然后import引用。
jhdlzx 2009-04-24
  • 打赏
  • 举报
回复
3楼说的刚试了,还是不行,只是将DIV中内容居中了,但整个DIV在页面中一旦点其中链接就不居中了
huxinghuo123 2009-04-24
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhanglei_love2008 的回复:]
所有的 <div align="center"> </div>
[/Quote]
这个应该行的...
中年秃头大叔 2009-04-24
  • 打赏
  • 举报
回复
所有的<div align="center"></div>
ly198706 2009-04-21
  • 打赏
  • 举报
回复
<body style="text-align:center;">
试试``我也是菜鸟。。。呵呵
CeShenBeiWang 2009-04-21
  • 打赏
  • 举报
回复
up

62,025

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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