js切换背景颜色
<!-------change the background color-------------->
<script>
function color1(event)
{
var cubebody=document.getElementById('body_color');
cubebody.className = 'graydient1';
}
function color2()
{
var cubebody=document.getElementById('body_color');
cubebody.className = 'graydient2';
}
function color3()
{
var cubebody=document.getElementById('body_color');
cubebody.className = 'graydient3';
}
function color4()
{
var cubebody=document.getElementById('body_color');
cubebody.className = 'graydient4';
}
</script>
<style>
/* 下拉按钮样式 */
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
} /* 容器 <div> - 需要定位下拉内容 */
.dropdown {
position: fixed;
left: 50px;
top: 20px;
display: inline-block;
} /* 下拉内容 (默认隐藏) */
.dropdown-content {
display: none;
position: absolute;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
} /* 下拉菜单的button */
.dropdown-content button {
background-color: #4CAF50;
border-radius: 6px;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
} /* 鼠标移上去后修改下拉菜单链接颜色 */
.dropdown-content a:hover {background-color: #f1f1f1} /* 在鼠标移上去后显示下拉菜单 */
.dropdown:hover .dropdown-content {
display: block;
} /* 当下拉内容显示后修改下拉按钮的背景颜色 */
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
</style> <div class="dropdown">
<button class="dropbtn">Background</button>
<div class="dropdown-content">
<button onMouseDown="color1(event)">type 1</button>
<button onMouseDown="color2()">type 2</button>
<button onMouseDown="color3()">type 3</button>
<button onMouseDown="color4()">type 4</button>
</div>
</div>
<!--------change color end---------->
第二部分:css
@charset "utf-8";
/* change the color of background */
.graydient1{
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#fce6bc+0,f8a500+42,f8a500+51,f8a500+61,fbd893+100 */
background: #fce6bc; /* Old browsers */
background: -moz-linear-gradient(top, #fce6bc 0%, #f8a500 42%, #f8a500 51%, #f8a500 61%, #fbd893 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, #fce6bc 0%,#f8a500 42%,#f8a500 51%,#f8a500 61%,#fbd893 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #fce6bc 0%,#f8a500 42%,#f8a500 51%,#f8a500 61%,#fbd893 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fce6bc', endColorstr='#fbd893',GradientType=0 ); /* IE6-9 */
}
.graydient2{
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#8e8e8e+0,8e8e8e+28,0c0c0c+45,010101+50,0a0a0a+59,4a4a4a+76,353535+87,1a1a1a+100 */
background: #8e8e8e; /* Old browsers */
background: -moz-linear-gradient(top, #8e8e8e 0%, #8e8e8e 28%, #0c0c0c 45%, #010101 50%, #0a0a0a 59%, #4a4a4a 76%, #353535 87%, #1a1a1a 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, #8e8e8e 0%,#8e8e8e 28%,#0c0c0c 45%,#010101 50%,#0a0a0a 59%,#4a4a4a 76%,#353535 87%,#1a1a1a 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #8e8e8e 0%,#8e8e8e 28%,#0c0c0c 45%,#010101 50%,#0a0a0a 59%,#4a4a4a 76%,#353535 87%,#1a1a1a 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8e8e8e', endColorstr='#1a1a1a',GradientType=0 ); /* IE6-9 */
}
.graydient3{
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#cfe0e9+0,aacede+17,61acc7+35,3a9cc2+52,42b6d6+59,4cd8f0+71,3aa5c2+84,26688c+100 */
background: #cfe0e9; /* Old browsers */
background: -moz-linear-gradient(top, #cfe0e9 0%, #aacede 17%, #61acc7 35%, #3a9cc2 52%, #42b6d6 59%, #4cd8f0 71%, #3aa5c2 84%, #26688c 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, #cfe0e9 0%,#aacede 17%,#61acc7 35%,#3a9cc2 52%,#42b6d6 59%,#4cd8f0 71%,#3aa5c2 84%,#26688c 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #cfe0e9 0%,#aacede 17%,#61acc7 35%,#3a9cc2 52%,#42b6d6 59%,#4cd8f0 71%,#3aa5c2 84%,#26688c 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cfe0e9', endColorstr='#26688c',GradientType=0 ); /* IE6-9 */
}
.graydient4{
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#ebeded+1,ebeded+12,d2d3da+28,afb1bf+49,d3d6db+77,ebeded+100 */
background: #ebeded; /* Old browsers */
background: -moz-linear-gradient(top, #ebeded 1%, #ebeded 12%, #d2d3da 28%, #afb1bf 49%, #d3d6db 77%, #ebeded 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, #ebeded 1%,#ebeded 12%,#d2d3da 28%,#afb1bf 49%,#d3d6db 77%,#ebeded 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to bottom, #ebeded 1%,#ebeded 12%,#d2d3da 28%,#afb1bf 49%,#d3d6db 77%,#ebeded 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ebeded', endColorstr='#ebeded',GradientType=0 ); /* IE6-9 */
}
js切换背景颜色的更多相关文章
- 关于更改MYECLIPSE JS 代码背景颜色
白色的背景,看花了眼,你想改一下编辑器的背景颜色,移步这里就可以了. 这时你高兴的打开编辑器,发现颜色确实变了,但是当你打开有JS的JSP时,你碉堡了,发现JS的背景颜色还是默认的, 看着让人纠结,好 ...
- js获取背景颜色
//js获取背景颜色var Airport=$("#Airport").css('background-color'); js设置背景颜色 $("#intercity&q ...
- 一个简单且丑陋的js切换背景图片基础示例
不多说,直接上代码,非常基础的一个原生js切换元素背景图片范例 <html> <head> <meta http-equiv="Content-Type&quo ...
- js随机背景颜色
// 要求: 随机生成颜色RGB 核心点 :(0,0,0) rgb 每一组的数字取值范围是 0~255 // 需要随机生成 0~255 之间的整数 function getRandom(min, ma ...
- android Button 切换背景,实现动态按钮和按钮颜色渐变
android Button 切换背景,实现动态按钮和按钮颜色渐变 一.添加android 背景筛选器selector实现按钮背景改变 1.右键单击项目->new->Oth ...
- [ASP.NET] [JS] GridView点击高亮当前选择行,并在点击另一行时恢复上一选择行背景颜色
在ASP.NET中的gridview控件里面可以通过设定其OnRowDataBound事件来进行实现高亮当前行的操作 前端控件的设置: 只要设置好OnRowDataBound属性即可,会自动在.cs文 ...
- css3动画之背景颜色的自动切换
因为不同浏览器内核的不同所以会产生浏览器兼容性问题 <!DOCTYPE html> <html> <head> <meta charset='utf-8'/& ...
- ext js 4.0 grid表格根据列值的不同给行设置不同的背景颜色
Code: Ext.create('Ext.grid.Panel', { ... viewConfig: { getRowClass: function(record) { return record ...
- 切换myEclipse工作空间后设置,myEclipse添加注释/设置豆沙背景颜色/调节字体大小
一.添加注释 操作位置: 注释规范 Files/** * @文件名称: ${file_name} * @文件路径: ${package_name} * @功能描述: ${todo} * @作者: ${ ...
随机推荐
- 【PyQt5-Qt Designer】QSlider滑块
QSlider滑块 QSlider简介 QSlider小部件提供了一个垂直或水平滑块. 滑块是控制有界值的经典控件.它允许用户沿水平或垂直凹槽移动滑块手柄,并将手柄的位置转换为合法范围内的整数值. Q ...
- mysql之event
mysql之event http://blog.csdn.net/lxgwm2008/article/details/9088521 Mysql事件调度器(Event Scheduler)类似于定时器 ...
- 20190316 Python - Pandas
1. python 安装3.7版本 2. 第三方包进行数据加工和呈现 需要注意的是,你安装过程中会有很多依赖包问题,如果网络异常,那么就使用https://pypi.org/ 地址去找对应的包下载 ...
- 爬虫请求库——selenium
selenium模块 selenium最初是一个自动化测试工具,而爬虫中使用它主要是为了解决requests无法直接执行JavaScript代码的问题.selenium的缺点是效率会变得很慢. sel ...
- grub启动流程和配置
grub stage 1 MBR中前 446个字节,如果把这里面的内容损坏,那么系统会认为当前磁盘没有启动引导功能,会尝试从光盘或者网络启动系统 grub stage 1.5 存放识别/boot ...
- System.getProperty("user.dir")
/**获得当前类的完整路径.最后一句*/package test;import java.net.MalformedURLException;import java.net.URI;import ja ...
- oracle sql小结(主要讲横列转换的例子)group by以及wmsys.wm_concat()的使用
---计算九月每个电厂的数量select f_dcname,count(f_dcname) as 九月份的数量 from W_EC_PLACESTATION_COLLECT twhere f_coll ...
- Go包管理工具Vendor使用
一.Go包管理工具Vendor 一.使用步骤 1.首先,从go get -u github.com/kardianos/govendor下载govendor工具到本地. 2.govendor使用时,必 ...
- fasttext与Linear SVC 分类测试结果
任务:分类出优质问题与非优质问题.任务背景:用户实际与智能客服交互的时候,如果只做阈值限制,在相似问题匹配的时候(由于词的重复),依然会匹配出部分结果.如:问题为 "设置好了?", ...
- script命令录屏
关于linux上的操作,我们的确可以使用'history'命令来显示出来操作记录,但是有些时候,我们不仅仅需要知道做了什么,还需要知道操作的时候,产生了什么效果,这个时候‘history’命令就显示无 ...