Jquery 使用引导更改表格标题颜色
我有一个使用引导的MVC5应用程序。表列名为黑色 在白色背景上,我想将其更改为蓝色背景和列 名字将是白色的,我怎么能这样做? 我试图玩CSS类,但没有成功Jquery 使用引导更改表格标题颜色,jquery,css,jquery-ui,twitter-bootstrap,Jquery,Css,Jquery Ui,Twitter Bootstrap,我有一个使用引导的MVC5应用程序。表列名为黑色 在白色背景上,我想将其更改为蓝色背景和列 名字将是白色的,我怎么能这样做? 我试图玩CSS类,但没有成功 <input type="button" value="Add" onclick="addRow()" class="data-button" id="add-row" /> <table class="table" > <tr> <th>
<input type="button" value="Add" onclick="addRow()" class="data-button" id="add-row" />
<table class="table" >
<tr>
<th>
@Html.DisplayNameFor(model => model.name)
</th>
<th>
@Html.DisplayNameFor(model => model.checkBox1)
</th>
<th></th>
</tr>
@DisplayNameFor(model=>model.name)
@DisplayNameFor(model=>model.checkBox1)
//使用css
蓝先生{
背景色:蓝色!重要;
}
蓝th{
颜色:白色!重要;
}
//html
.....
在CSS中
th {
background-color: blue;
color: white;
}
试试这个:
table.table tr th{background-color:blue !important; font-color:white !important;}
希望这对您有所帮助。以下是另一种分隔表头和表体的方法:
thead th {
background-color: #006DCC;
color: white;
}
tbody td {
background-color: #EEEEEE;
}
请看一下此示例,了解如何分离桌子的头部和主体 您只需将其中一个引导应用于标题行即可。在本例中(蓝色背景,白色文本):主
名字
姓
约翰
雌鹿
简
鱼子
有一个bootstrap函数,用于更改表格标题的颜色,对于表格标题的深色背景,该函数称为thead dark,对于表格标题的浅色背景,该函数称为thead light。使用此函数后,您的代码将如下所示
<table class="table">
<tr class="thead-danger">
<!-- here I used dark table headre -->
<th>
@Html.DisplayNameFor(model => model.name)
</th>
<th>
@Html.DisplayNameFor(model => model.checkBox1)
</th>
<th></th>
</tr>
@DisplayNameFor(model=>model.name)
@DisplayNameFor(model=>model.checkBox1)
这将使整个表格背景变为蓝色,并且不会按照OP的要求更改文本颜色。谢谢David,CSS在哪里?在site.CSS文件中?我应该如何在代码中引用它?将它添加到site.css,模板应该已经引用了它,这样您就不需要做任何其他事情了。非常感谢David,投票通过了!它可以工作,但我有一些问题,当我点击AddRow并将新行添加到表中时,它也有相同的蓝色和白色,我如何避免它?这是在单击时添加行的代码…var html='@html.TextBox(“Name”)@html.CheckBox(“checkBox1”)@html.CheckBox(“checkBox2”)@html.CheckBox(“checkBox3”);谢谢,但是我应该把它放在哪里呢?你有一个style.css或者你正在使用的任何css文件,你可以在它的底部写。没有字体颜色这样的css属性,也可以使用!这是一种不太“黑”的方法,因为它不使用自定义CSS,而是使用Boostrap的CSS类。但它只允许您从已知的颜色类别danger
,info
,success
,primary
和warning
中进行选择,这可能有点有限。但也许这根本不是正确的CSS类?再想想!还有`表-*`颜色类。(英国标准4.0.0)
<table class="table">
<tr class="thead-danger">
<!-- here I used dark table headre -->
<th>
@Html.DisplayNameFor(model => model.name)
</th>
<th>
@Html.DisplayNameFor(model => model.checkBox1)
</th>
<th></th>
</tr>