一个奇怪的问题

woshizhaoxuhui 2014-01-16 09:57:27
如下一段代码,第一个div中的button无法居中,二第二个div中的label可以居中;
但如果屏蔽第一个div,则第二个div中的label就无法居中,想请教这会是什么问题?这段代码是写在一个母版里的,会不会是母版影响?
<div style="width:800px;margin:0 auto;">
<cener />
<asp:Button ID="btnAdd" runat="server" Text="添加角色" />
</div>
<div style="width:100%;margin-left: auto;margin-right: auto;">
<center/>
<asp:Label ID="Label1" runat="server" Text="个人月度工作报告" Font-Bold="True"
Font-Names="宋体" Font-Size="15pt"></asp:Label>
</div>
...全文
266 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
天空丶蒋 2014-01-18
  • 打赏
  • 举报
回复
<div style="width:800px;margin:0 auto;"> <cener /> <asp:Button ID="btnAdd" runat="server" Text="添加角色" /> </div> <div style="width:100%;margin-left: auto;margin-right: auto;"> <center/> <asp:Label ID="Label1" runat="server" Text="个人月度工作报告" Font-Bold="True" Font-Names="宋体" Font-Size="15pt"></asp:Label> </div> 明明第一个居中有问题!!没看出来??
md5e 2014-01-17
  • 打赏
  • 举报
回复
引用 8 楼 woshizhaoxuhui 的回复:
所以我觉得很有可能是母版有影响
发你浏览器生成后的html源代码出来才知道
woshizhaoxuhui 2014-01-17
  • 打赏
  • 举报
回复
所以我觉得很有可能是母版有影响
lyx266 2014-01-16
  • 打赏
  • 举报
回复
<div style="width:800px;margin:0 auto 0 auto; text-align:center;">
md5e 2014-01-16
  • 打赏
  • 举报
回复
引用 3 楼 woshizhaoxuhui 的回复:
修改错误后,第一个div中的button仍然不能居中啊。。。


你改对没有,三个浏览器都没有问题


小猪八Q 2014-01-16
  • 打赏
  • 举报
回复
浏览器兼容性问题,实测Chrome浏览器下,没有问题,显示正常。 是第一个div的margin:0 auto;没有起作用,也就是第一个div没能居中显示,而他里面的内容是相对div居中显示的。
woshizhaoxuhui 2014-01-16
  • 打赏
  • 举报
回复
最困惑的地方就是在第二个div,有第一个时能居中,第一个div屏蔽掉后就不能居中了,感觉好像是有外部影响似的
woshizhaoxuhui 2014-01-16
  • 打赏
  • 举报
回复
修改错误后,第一个div中的button仍然不能居中啊。。。
md5e 2014-01-16
  • 打赏
  • 举报
回复
<div style="width:800px;margin:0 auto;"> <center /> <asp:Button ID="btnAdd" runat="server" Text="添加角色" /> </div> <div style="width:100%;margin-left: auto;margin-right: auto;"> <center/> <asp:Label ID="Label1" runat="server" Text="个人月度工作报告" Font-Bold="True" Font-Names="宋体" Font-Size="15pt"></asp:Label> </div>
md5e 2014-01-16
  • 打赏
  • 举报
回复
<div style="width:100%;margin-left: auto;margin-right: auto;"> <center /> <asp:Button ID="btnAdd" runat="server" Text="添加角色" /> </div> <div style="width:100%;margin-left: auto;margin-right: auto;"> <center/> <asp:Label ID="Label1" runat="server" Text="个人月度工作报告" Font-Bold="True" Font-Names="宋体" Font-Size="15pt"></asp:Label> </div>

62,243

社区成员

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

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

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

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