在不影响其他HTML表格的情况下,使用CSS表格的最快捷方式 [英] fastest way to use css for html table without affecting another html table

查看:104
本文介绍了在不影响其他HTML表格的情况下,使用CSS表格的最快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的css位于 http://sillybean.net/css/seaglass.css和我想只使用这个CSS的一个HTML表,在同一页上我有多个HTML表,所以我不想影响其他HTML表。在 http://sillybean.net/css/seaglass上进行少量修改的最快方式是什么? css

My css is located at http://sillybean.net/css/seaglass.css and i want to use this css for only one of html table, On the same page i have multiple html tables so i do not want to affect other html tables. What is the fastest way to do it with less modification on http://sillybean.net/css/seaglass.css ?

推荐答案

您可以将一个类应用于要影响的表,然后在该表中使用该类你的CSS?

Can you just apply a class to the table you want to affect, then use that class in your CSS?

在你的HTML中,你可以输入:

In your HTML, you can put:

<table class="mytable">
... CONTENT OF THE TABLE, AS NORMAL ...
</table>

然后,将类选择器添加到您的CSS:

And then, add the class selector to your CSS:

table.mytable { border-collapse: collapse; border: 1px solid #839E99;
                background: #f1f8ee; font: .9em/1.2em Georgia, "Times New Roman", Times, serif; color: #033; }
.mytable caption { font-size: 1.3em; font-weight: bold; text-align: left; padding: 1em 4px; }
.mytable td,
.mytable th { padding: 3px 3px .75em 3px; line-height: 1.3em; }
.mytable th { background: #839E99; color: #fff; font-weight: bold; text-align: left; padding-right: .5em; vertical-align: top; }
.mytable thead th { background: #2C5755; text-align: center; }
.mytable .odd td { background: #DBE6DD; }
.mytable .odd th { background: #6E8D88; }
.mytable td a,
.mytable td a:link { color: #325C91; }
.mytable td a:visited { color: #466C8E; }
.mytable td a:hover,
.mytable td a:focus { color: #1E4C94; }
.mytable th a,
.mytable td a:active { color: #fff; }
.mytable tfoot th,
.mytable tfoot td { background: #2C5755; color: #fff; }
.mytable th + td { padding-left: .5em; }

这篇关于在不影响其他HTML表格的情况下,使用CSS表格的最快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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