Gridview CSS 边框不一致
这真的很困扰我。我正在使用 GridView 并希望对其进行格式化,以便边框在所有浏览器中显示相同。目前,我在 IE、FF 和 Chrome 之间得到了不同的结果。我不确定我的 CSS 做错了什么(我对 CSS 还很陌生),但某些东西一定是正确的,因为其中一个浏览器随时都能正确显示边框。 gridview CSS 如下:
.gridViewData
{
height:auto;
width:544px;
position:relative;
text-align:center;
background-color:#7D9EBA;
border:solid thin black;
border-right:none 0px black;
}
.gridViewData td
{
padding:2px;
border-top-style:none;
border-bottom-style:solid;
border-left-style:solid;
border-right-style:none;
border-color:Black;
border-width:thin;
}
.gridViewData th
{
height:10px;
width: 544px;
position:relative;
text-align:center;
border-top-style:dashed;
border-bottom-style:solid;
border-left-style:solid;
border-right-style:none;
border-color:Black;
border-width:thin;
background-color:white;
}
.gridViewData .alt
{
background-color:Red;
}
.gridViewData .pgr
{
background-color:Orange;
}
我希望表格看起来像绘图的粗略尝试:D。标题单元格之间不应有边框。
____________________________
|____________________________|
|___|__________|________|____|
|___|__________|________|____|
|___|__________|________|____|
在 IE 中,标题没有上边框。在 FF 中,它看起来不错,在 Chrome 中,标题中有分隔符。 这已经困扰我一段时间了,所以希望有人能对此有所启发。
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 GridView 属性来实现此目的,而不是将 CSS 应用于生成的表元素。例如,可以通过将 CSS 应用于属性来设置标题样式:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.headerstyle.aspx
编辑:
请注意,声明性 bordercolor 属性添加了一个内联样式声明,该声明仅适用于表格本身,不适用于单个单元格。以编程方式添加 bordercolor 属性不使用内联样式,而是使用 HTML bordercolor 属性,浏览器将其应用于表格内的所有边框:
我发表了一篇关于此的博客文章 - 检查 Lee Dumond 的评论:
http://www.codersbarn.com/post /2009/05/31/Set-Color-of-GridLines-in-Gridview.aspx#comment
Use the GridView properties to achieve this rather than applying CSS to the generated table elements. For example, the header can be styled by applying the CSS to the property:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.headerstyle.aspx
EDIT:
Note that the declarative bordercolor attribute adds an inline style declaration which only applies to the table itself, not individual cells. Adding the bordercolor attribute programmatically does not use an inline style, but uses the HTML bordercolor property, which browsers apply to ALL borders inside the table:
I put out a blog post about this - check Lee Dumond's comment:
http://www.codersbarn.com/post/2009/05/31/Set-Color-of-GridLines-in-Gridview.aspx#comment