html颜色交替(html颜色对照表)
华为云服务器特价优惠火热进行中! 2核2G2兆仅需 38 元;4核4G3兆仅需 79 元。购买时间越长越优惠!更多配置及优惠价格请咨询客服。
合作流程: |
本篇文章给大家谈谈html颜色交替,以及html颜色对照表对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
微信号:cloud7591如需了解更多,欢迎添加客服微信咨询。
复制微信号
本文目录一览:
- 1、在html中,用外部样式表控制表格格式等,那么如何在这个外部样式表中设置奇偶行交替色彩
- 2、关于设置html中表格颜色交替的问题
- 3、HTML颜色切换
- 4、怎样能使html的外部样式表奇偶行交替色类似?
在html中,用外部样式表控制表格格式等,那么如何在这个外部样式表中设置奇偶行交替色彩
可以使用css3的奇偶选择器,如:
li:nth-child(odd){background-color:#FFE4C4;}
li:nth-child(even){background-color:#F0F0F0;}
li:nth-child(odd)是设置奇数行的背景色,li:nth-child(even)是设置偶数行的。但是css3不兼容IE9以下的浏览器,如果需要考虑到兼容问题的话,可以使用jq设置,如
$("ul li:nth-child(even)").css("background-color","#FFE4C4"); //设置偶数行的背景色
$("ul li:nth-child(odd)").css("background-color","#F0F0F0"); //设置奇数行的背景色
关于设置html中表格颜色交替的问题
html xmlns=""
head
title表格效果/title
style type="text/css"
.highlight
{
background-color: red;
}
.selected
{
background-color: blue;
}
.style1
{
width: 247px;
}
.tr_w{background-color: white; }
.tr_g{background-color: #808080; }
/style
script src="JS/jquery-1.4.2.min.js" type="text/javascript"/script
script type="text/javascript"
$(function () {
$("tr").click(function () {
$(this).toggleClass("selected");
});
$("tr").hover(
function () { $(this).removeClass("tr_g tr_w").addClass("highlight"); },
function () { if(!$(this).hasClass("selected")){table_tr();$(this).removeClass("highlight");} }
);
table_tr();
});
function table_tr(){
$("tr:odd").addClass("tr_g"); //先排除第一行,然后给奇数行添加样式
$("tr:even").addClass("tr_w"); //先排除第一行,然后给偶数行添加样式
}
/script
/head
body
div id="main"
table border="1"; style="height: 79px; width: 827px;"
tr
td
12
/td
td
12
/td
td
12
/td
/tr
tr
td
12
/td
td
12
/td
td
12
/td
/tr
/table
/div
/body
/html
给你改了点样式,和修改了一点js代码

HTML颜色切换
用a标签就可以实现。如:
html:
a href="javascript:void(0)首页/a
a href="javascript:void(0)电视剧/a
css:
a{display:block; width:100px; line-height:25px; float:left; color:#333;background-color:#fff;}
a:hover{background-color:#228B22;color:#fff;}
怎样能使html的外部样式表奇偶行交替色类似?
jQuery中设置html的外部样式表的奇偶行交替色类似:
设置偶数行的背景色:$("table tr:nth-child(even)").css("background-color","#FFE4C4");
设置奇数行的背景色:$("table tr:nth-child(odd)").css("background-color","#F0F0F0");
可以使用css3的奇偶选择器:
tr:nth-child(odd){background-color:#FFE4C4;}。
tr:nth-child(even){background-color:#F0F0F0;}li:nth-child(odd)是设置奇数行的背景色,li:nth-child(even)是设置偶数行的。
参考资料
jQuery中设置html的外部样式表的奇偶行交替色类似.博客[引用时间2018-1-5]
html颜色交替的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于html颜色对照表、html颜色交替的信息别忘了在本站进行查找喔。
