如何覆写td align =" center" ;? [英] How to override td align="center"?
问题描述
摘自为什么align =" center"不重写在{text-align:right;} 这篇文章,CSS应该对旧式布局属性采取预知。我正在开发一个项目,我必须在一个单元格中注入内容的格式为:
< td align =center ; ...< / td>
我不想让我的内容居中,试图使用text-align = 不会覆盖td标签,如文章中建议的。
如果允许更改td的内容,您可以然后使用text-align:left的另一个标签包装td值;
结果标签为:
< td align =center>
< div class =left> content here< / div>
< / td>
这是新的CSS:
td div.left {text-align:left; }
如果不能修改单元格值,另一个办法是使用javascript修改align属性,在jquery中:
$(document).ready(function(){
$('td [align = center ]')。attr('align','left');
// $('td [align = center]')。attr('align','left')。css ','left'); //或仍然不工作
});
as gathered from Why align="center" not overriding on {text-align:right;} this article, CSS should take prescience over old-style layout attributes. I am working on a project where I have to inject content in a cell that has the format:
<td align="center">...</td>
I do not want my content to be centered, trying to use text-align="left" does not override the td-tag, as suggested in the article. What can I do to override the TD align attibute?
If you are allowed to change the content of the td, you can then wrap the td values with another tag with text-align:left;
Resulting Tag would be:
<td align="center">
<div class="left">content here</div>
</td>
Here is the new CSS:
td div.left { text-align:left; }
If you cannot modify the cell value, another work around is to modify the align attribute using javascript, In jquery:
$(document).ready(function(){
$('td [align=center]').attr('align','left');
// $('td [align=center]').attr('align','left').css('text-align','left'); //or still not working
});
这篇关于如何覆写td align =" center" ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!