防止继承? [英] Preventing Inheritance?

查看:82
本文介绍了防止继承?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将一个边框应用于一个表的列,而不是应用于列中嵌入的表的嵌套表(我知道嵌套表是不好的形式,它是

客户请求)。我无法控制这张桌子里面的东西所以

将一个类应用到任何取消这个边界的嵌套表格

不是一个选项。有没有办法阻止继承?

解决方案

Bob写道:

我需要申请一个边界到一个表的列,但不是嵌套在其中的表的列(我意识到嵌套表是坏形式,它是客户端请求)。我无法控制这张桌子里面的内容所以
将一个类应用到任何取消这个边界的嵌套表格
不是一个选择。有什么方法可以阻止继承吗?




这听起来好像遗产不是问题所在,但是那些元素你好吗?b $ b don不想匹配你的风格定义是否匹配它以及你想要匹配的



看看后代选择器< http ://w3.org/TR/CSS2/>并为嵌套元素指定一个

不同的值。


-

David Dorward< http:// dorward。 me.uk/>


" Bob" <博****** @ hotmail.com>在消息中写道

新闻:a4 ************************* @ posting.google.co m ... < blockquote class =post_quotes>我需要将一个边框应用于一个表的列,而不是嵌套在其中的表的列(我意识到嵌套表是不好的形式,它是
客户要求)。我无法控制这张桌子里面的内容所以
将一个类应用到任何取消这个边界的嵌套表格
不是一个选择。有没有办法阻止继承?




也许你应该给你的表一个ID并将样式应用到ID

选择器。


HTH

问候,

Peter Foti


David Dorward <做***** @ yahoo.com>在消息新闻中写道:< c0 ******************* @ news.demon.co.uk> ...

看看后代选择器< http://w3.org/TR/CSS2/>并为嵌套元素指定一个不同的值。




问题是我会在所有
$ b $上强制使用不同的值b嵌套元素。例如,如果我尝试在嵌套表(border:none)上删除边框样式

,则属性为border = 1

的表也会丢失边界。


I need to apply a border to a table''s columns, but not to the columns
of tables nested within (I realize nested tables are bad form, it''s a
client request). I can''t control what goes inside this table so
applying a class to any nested tables that cancels out this border
isn''t an option. Is there any way to prevent the inheritance?

解决方案

Bob wrote:

I need to apply a border to a table''s columns, but not to the columns
of tables nested within (I realize nested tables are bad form, it''s a
client request). I can''t control what goes inside this table so
applying a class to any nested tables that cancels out this border
isn''t an option. Is there any way to prevent the inheritance?



It sounds like inheritance isn''t the problem here, but that elements you
don''t want to match your style definition are matching it as well as ones
you want to match.

Take a look at descendent selectors <http://w3.org/TR/CSS2/> and specify a
different value for the nested elements.

--
David Dorward <http://dorward.me.uk/>


"Bob" <bo******@hotmail.com> wrote in message
news:a4*************************@posting.google.co m...

I need to apply a border to a table''s columns, but not to the columns
of tables nested within (I realize nested tables are bad form, it''s a
client request). I can''t control what goes inside this table so
applying a class to any nested tables that cancels out this border
isn''t an option. Is there any way to prevent the inheritance?



Perhaps you should give your table an ID and apply the style to the ID
selector.

HTH
Regards,
Peter Foti


David Dorward <do*****@yahoo.com> wrote in message news:<c0*******************@news.demon.co.uk>...

Take a look at descendent selectors <http://w3.org/TR/CSS2/> and specify a
different value for the nested elements.



The problem is I would then be forcing that different value on all
nested elements. For example if I attempt to remove the border style
on nested tables (border:none), a table with the attribute "border=1"
would also lose its border.


这篇关于防止继承?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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