2014-03-24 46 views
0

我有一个用ASP.NET GridView生成的表,并且我必须在每个<tr>之间放置一些空间。用于选择器的css样式<tr>用asp.net gridview

在我的CSS文件,我有<tr>选择说明:

.tr { 
    margin-bottom: 5px; 
} 

但是,使用浏览器的开发人员工具,我认为成立风格<tr>是从我的CSS文件中未使用的,但它有“用户自定义样式表“,即使在浏览器开发人员工具中,我也无法更改margin-bottom

那么,这是什么问题?

+0

'.tr'针对一个名为 “TR” 类,很可能你想要的目标'tr'它将匹配“tr”类型的元素。 – jball

回答

2

您已创建选择器名称为“tr”,通过在句点前添加一个句点,所以您不是针对元素本身,而是针对具有class="tr"的任何元素。尝试丢弃.

tr { 
    margin-bottom: 5px; 
} 

要小心,不过,你可能不希望影响您的网站的每一个<tr>。也许你指定的GridView<asp:GridView CssClass="fatrows" />)一个特殊的类,然后针对其行略有更具体的CSS:

table.fatrows tr { 
    margin-bottom: 5px; 
} 

或通过其行项目指定一个特殊的CSS类粘到GridView约定:

<asp:GridView> 
    <RowStyle CssClass="fatrows" /> 
</asp:GridView> 

和目标的行本身:

tr.fatrows { 
    margin-bottom: 5px; 
} 

显然,你会想拿出一个更有意义的类名称...

1

你有什么:

.tr /* incorrectly targets elements with the class "tr" */ { 
    margin-bottom: 5px; 
} 

你需要什么:

tr /* targets elements of type TR */ { 
    margin-bottom: 5px; 
}