博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
1.2 网页换肤
阅读量:4605 次
发布时间:2019-06-09

本文共 2097 字,大约阅读时间需要 6 分钟。

中心主题:通过点击按钮对网页的样式进行切换,主要是控制<link>的href属性--

进行切换

一、HTML结构

二、css样式

body{
margin:0px; padding:0px; box-sizing: border-box; } div{
width: 200px; margin:0px auto; } #changeSkin{
float: left; width:100%; overflow: hidden; zoom:1; margin:10px 0; } #changeSkin>li{
float: left; list-style-type: none; text-indent:-9999px; border-width:4px; border-style:solid; width:10px; height:10px; margin-left:10px; margin-right:10px; } #red{
border-color: red; background-color: red; } #green{
border-color: lightseagreen; background-color: lightseagreen; } #blue{
border-color: blue; background-color: blue; } .current{
background-color: white!important; } #contList{
float: left; width:100%; } #contList li{
list-style-type: none; float: left; width:25%; margin-top:10px; color: #000; } #contList li a{
color: #ffffff; }

引入的外部文件样式:

1.blue.css

 

 body{

font-weight:bold;">blue; }

2.green.css

body{
font-weight:bold;">green; }

3.red.css

body{
font-weight:bold;">red; }

三、jquery文件

 
$(document).ready(function(){        var $skin=$("#changeSkin li");        var $link=$("link");        $skin.click(function(){            $(this).addClass("current");            $skin.not(this).removeClass("current");            var $id=$(this).attr("id");            $link.attr("href",$id+".css");        });    });

 

 四、最终结果

blue样式:

green样式:

red样式:

转载于:https://www.cnblogs.com/wuliwuli/p/5718155.html

你可能感兴趣的文章
STM32F0使用LL库实现SHT70通讯
查看>>
Atitit. Xss 漏洞的原理and应用xss木马
查看>>
MySQL源码 数据结构array
查看>>
(文件过多时)删除目录下全部文件
查看>>
T-SQL函数总结
查看>>
python 序列:列表
查看>>
web移动端
查看>>
pythonchallenge闯关 第13题
查看>>
linux上很方便的上传下载文件工具rz和sz使用介绍
查看>>
React之特点及常见用法
查看>>
【WEB前端经验之谈】时间一年半,或沉淀、或从零开始。
查看>>
优云软件助阵GOPS·2017全球运维大会北京站
查看>>
linux 装mysql的方法和步骤
查看>>
poj3667(线段树区间合并&区间查询)
查看>>
51nod1241(连续上升子序列)
查看>>
SqlSerch 查找不到数据
查看>>
集合相关概念
查看>>
Memcache 统计分析!
查看>>
(Python第四天)字符串
查看>>
个人介绍
查看>>