简体   繁体   English

无法从外部样式表样式化TD元素

[英]Trouble styling TD elements from external stylesheet

I'm trying to port code over from using inline css to using a stylesheet and as I'm pretty much a total css noob I'm having trouble. 我正在尝试将代码从使用内联css移植到使用样式表,由于我几乎是一个整体css noob,我遇到了麻烦。

Most of the things I've moved over to external have worked fine, but I can't seem to get TD elements to use styles defined in the stylesheet. 我移到外部的大多数东西都工作正常,但是我似乎无法让TD元素使用样式表中定义的样式。 Here's an example: 这是一个例子:

<td class="text_right">...</td>


.text_right {
text-align: right;
}

Why doesn't that work? 为什么不起作用?

That should work, however bear in mind that your <td> element should have some dimensions, otherwise it will be as wide as the content. 那应该起作用,但是请记住,您的<td>元素应具有某些尺寸,否则它将与内容一样宽。

Check this for a demo 检查演示

<td class="text_right"><a>...</a></td>    

.text_right {
text-align: right;
width: 300px;
}

that should work , put you text in <a> tags 应该起作用,将文本放在<a>标记中

Try using !important . 尝试使用!important。 Like this ; 像这样 ;

.text_right {
text-align: right !important;
}

if you still see it not aligned please check css for that element overridden rules (with chrome or opera) by right click and investigate 如果您仍然看到它未对齐,请通过右键单击检查该元素的CSS覆盖规则(使用Chrome或Opera)并进行调查

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 样式化Raphael从外部样式表创建的VML元素 - Styling VML elements created by Raphael from an external stylesheet 使用外部样式表设置 PHP 输出样式 - Styling PHP Output with an External Stylesheet Нow 提供 HTML web 页面,同时从外部样式表呈现 CSS 样式 - ZBC4150D023D31AC9F2D3 被忽略6713 - Нow to serve an HTML web page while rendering the CSS styling from an external stylesheet - styles being ignored <td style=“width”>属性可以内联,但不能在外部样式表中使用 - <td style=“width”> attribute works inline but not in external stylesheet 来自 css 样式表的 React 类样式不起作用 - React class styling from css stylesheet not working 内联或来自样式表的Firebug或IEDevtoolbaar样式 - Firebug or IEDevtoolbaar styling inline or from stylesheet 从javascript修改外部样式表 - modify external stylesheet from javascript 在样式表中为一个类下的多个元素设置样式的快捷方式 - Shortcut for styling multiple elements under one class in a stylesheet 在我的样式表中引用元素时遇到问题 - Having trouble referencing elements in my styling sheet CGridView样式特定的列,插入 <div> 内 <td> 元素 - CGridView styling specific column, inserting <div> inside <td> elements
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM