用CSS覆盖HTML width属性 [英] Overwrite HTML width property with CSS

查看:280
本文介绍了用CSS覆盖HTML width属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在CSS中不使用CSS类覆盖表的HTML属性宽度?

Is it possible to overwrite the HTML property width of a table without using CSS classes in CSS?

我没有运气就尝试过这样的事情:

I tried something like this without any luck:

<table cellpadding="0" cellspacing="0" width="180">
    <tbody>
        <tr>
            <td bgcolor="#f0f0f0">
                <img style="display:block;" border="0" src="menu_up.jpg" alt=" " width="20" height="64">
            </td>
         </tr>
    </tbody>
</table>

CSS:

@media only screen and (max-device-width: 480px) {

    td[width=180] {
        width: 100px !important;
    }

}

有什么想法吗?

不胜感激.

推荐答案

是的,这是可能的.您只需要选择table而不是td,并且应该将width属性的值放在引号中(只需尝试一下即可).

Yes, this is possible. You just need to select the table and not the td and you should put the value of the width attribute in quotes (just tried it out).

table[width="180"] {
    width: 100px !important;
}

这篇关于用CSS覆盖HTML width属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆