虽然在网上找了一些例子,但是并没有解决我的问题。希望可以有人帮帮我。 我有两个 CSS 文件。一种是重置所有样式属性。有代码(片段)
html, body, body div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp, small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, figure, footer, header, hgroup, menu, nav, section, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}
由于规则,我无法修改 reset.css。我只处理 style.css。我做了一些事情来使 HeaderStyle 起作用。我创建了一个新类并且它有效。
tr.dgrdHeaderfntsize13e td
{
font-size: 1.4em; /* 1.3em 11px */
font-weight: bold;
background-color: #F2F7FA;
padding: 5px;
text-transform: none;
vertical-align: middle;
text-align: left;
}
我的问题是如何为单元格上的字体大小创建类。我尝试了 td.fntsize13e
并且 tr td.fntsize13e
不起作用。这是我的 .aspx 页面
<asp:DataGrid ID="dgrdLawyers" Runat="server" DataKeyField="GlobalID" GridLines="Both"
AutoGenerateColumns="false" CssClass="dgrdInnerBorders noOuterBorder talgnC"
CellPadding="5" >
<PagerStyle Mode="NumericPages" Position="Top" HorizontalAlign="Right" />
<%--<HeaderStyle CssClass="dgrdHeader talgnL fntsize13e"></HeaderStyle>--%>
<HeaderStyle CssClass="dgrdHeaderfntsize13e"></HeaderStyle>
<ItemStyle CssClass="dgrdItem talgnL fntsize13e"></ItemStyle>
最佳答案
验证您呈现的 html 是否正确并且没有将内联样式设置为...
<td style="font-size:20px;">asdf</td>
并且在您的 css 中,您可以使用 !important 强制属性值
td.fntsize13e {
font-size: 10px !important;
}
这应该可行,并且会强制调整字体大小,但我会尽量避免这种情况。找出真正设置字体大小的位置并将其修复。
关于css - 在 CSS 类中声明类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15121856/