我有内容,出现在一个企业网站内的iframe。有几个部门贡献了自己的CSS文件来管理整个UI和设计。
我的问题是,他们可能会在没有通知的情况下为td这样的元素使用选择器。当然,这将影响到框架中我自己的内容,除非我在每个td中添加一个类。我只是以td为例:任何元素的泛型样式都可能在没有通知的情况下改变。
有什么方法/惯例/实践可以用来保护我自己的造型吗?
发布于 2012-10-25 17:37:24
加载所有CSS文件后包括reset.css
:
html {
color: #000;
background: #FFF;
}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td {
margin: 0;
padding: 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
fieldset,img {
border: 0;
}
address,caption,cite,code,dfn,em,strong,th,var,optgroup {
font-style: inherit;
font-weight: inherit;
}
del,ins {
text-decoration: none;
}
li {
list-style: none;
}
caption,th {
text-align: left;
}
h1,h2,h3,h4,h5,h6 {
font-size: 100%;
font-weight: normal;
}
q:before,q:after {
content: '';
}
abbr,acronym {
border: 0;
font-variant: normal;
}
sup {
vertical-align: baseline;
}
sub {
vertical-align: baseline;
}
legend {
color: #000;
}
input,button,textarea,select,optgroup,option {
font-family: inherit;
font-size: inherit;
font-style: inherit;
font-weight: inherit;
}
input,button,textarea,select {
*font-size: 100%;
}
这将重置所有主选择器的默认值,删除任何突出的样式。
发布于 2012-10-25 21:04:34
通过将类或id添加到页面的主体标记中,为每个部门创建一个“命名空间”,然后确保每个部门的规则使用该命名空间。
例如;
body.personnel p {
color:red;
}
body.logistics p {
color:blue;
}
只要他们用body.departmentClassName修改他们的规则,你就应该能够保护你的CSS。
https://webmasters.stackexchange.com/questions/36080
复制相似问题