当前位置: 首页 > news >正文

深圳网站设计与制作公司seo排名赚app

深圳网站设计与制作公司,seo排名赚app,用wordpress做音乐网站,郑州市中标公示网CSS 手写switch 纯css手写switchcss变量 纯css手写switch 思路: switch需要的元素有:开关背景、开关按钮。点击按钮后,背景色变化,按钮颜色变化,呈现开关打开状态。 利用typecheckbox,来实现switch效果(修…

CSS 手写switch

  • 纯css手写switch
  • css变量

纯css手写switch

思路:

  1. switch需要的元素有:开关背景开关按钮。点击按钮后,背景色变化,按钮颜色变化,呈现开关打开状态。

  2. 利用type=checkbox,来实现switch效果(修改样式)。

细节:

  1. 开关背景可以在里面添加个<span>的作为被修改的背景。
  2. 开关按钮可以用伪元素来实现。
  3. 点击后颜色变化,可以根据checkbox特性,使用伪类选择器来添加改变背景色的样式,且通过伪类选择器,让伪元素移动位置。

前置知识一:

  1. 伪类选择器:
    概念:为处于某个状态的已有元素添加对应的样式,这个状态是根据用户行为而动态改变的。

    比如鼠标悬停hover效果,或者获取焦点focus效果。
    使用:用冒号表示


  2. 伪元素:
    概念:创建一些不在Dom树中的元素,并为其添加样式。
    使用:用双冒号表示。

前置知识二:正常来说,我们dispaly:none的时候,我们就不会触发隐藏元素的点击事件了。

对于type=checkbox,当我们在外层加一个<label>标签,就可以在隐藏input的时候,点击label触发选中事件,我们经常用这种方式来定义一些样式。

<!-- css实现switch开关 --><!-- 加一个label标签,当我们点击label标签的时候复选框会被选中 -->
<label class="switch"><input type="checkbox"><span class="slider"></span>
</label><style>:root{--switchWidth:90px;--switchHeight:40px;}/*前置操作:1. 外层定义switch的大小。2. 隐藏checkbox框。*//* 定义开关的大小 */.switch {position: relative;display: inline-block;width: var(--switchWidth);height: var(--switchHeight);}/* 隐藏原本的复选框 */.switch input {display: none;}/*第一步:1.定义switch的背景:让span标签,填充满父元素,用作switch的背景。2.定义switch的开关按钮:使用伪元素,给switch添加按钮。position:absolute会找离着自己最近的relative定位。*//* 开关背景 */.slider {position: absolute;  /* 子绝父相定位 */cursor: pointer;top: 0;left: 0;right: 0;bottom: 0;background-color: #eee;transition: .5s;    /* 过渡,所有的都0.5S */border-radius: 100px;}/* 开关按钮 */.slider::before {content: "";height: 30px;width: 30px;border-radius: 20px;position: absolute;left: 8px;bottom: 5px;background-color: #aeaaae;transition: .4s;}/*第二步:1.选中的时候更改起兄弟元素样式。也就是修改选中的背景色。2.选中的时候,开关按钮向左移动一段距离且改变颜色。*/input:checked + .slider{background: green;}	/* 使用伪类与伪元素。当input选中的时候,已经添加的伪类,颜色变白,且移动44px */input:checked + .slider::before{background-color: #fff;transform: translateX(44px);}
</style>

css变量

<style>:root{--size:200px;}	.box{height:var(--size);width:var(--size);background:red;}.box .item{height:calc(var(--size)/2);width:calc(var(--size)/2);background:green;}
</style>
<div class="box"><!-- css变量 --><!-- 使用方式:1.通过 " -- " 来定义一个css变量2.使用的时候,通过var方式引用。3.css变量同样可以用于计算。--><!--使用场景:css变量使用非常广泛,比如我们定义一个组件,如果不用变量的话,如果要改小宽度或者高度,是很麻烦的,会有连带效果。用变量以后会方便多。其次,可以方便于复用。--><div class="item"></div>
</div>

文章转载自:
http://dinncoknockabout.bkqw.cn
http://dinncofice.bkqw.cn
http://dinncoplausibly.bkqw.cn
http://dinncodamoiselle.bkqw.cn
http://dinncoaccessible.bkqw.cn
http://dinncodamningly.bkqw.cn
http://dinncoahriman.bkqw.cn
http://dinncomonobasic.bkqw.cn
http://dinncoknightage.bkqw.cn
http://dinncotaa.bkqw.cn
http://dinncodisfurnish.bkqw.cn
http://dinncocorsican.bkqw.cn
http://dinncorayl.bkqw.cn
http://dinncochaplain.bkqw.cn
http://dinncooenone.bkqw.cn
http://dinncojehad.bkqw.cn
http://dinncomucinolytic.bkqw.cn
http://dinncohyperlipaemia.bkqw.cn
http://dinncolevelpeg.bkqw.cn
http://dinncoindividualistic.bkqw.cn
http://dinncoyearlong.bkqw.cn
http://dinncopenoncel.bkqw.cn
http://dinncobroederbond.bkqw.cn
http://dinncocabana.bkqw.cn
http://dinncostockwhip.bkqw.cn
http://dinncobleacherite.bkqw.cn
http://dinncoeternize.bkqw.cn
http://dinncomoreover.bkqw.cn
http://dinncomodernism.bkqw.cn
http://dinncogeum.bkqw.cn
http://dinncosaccharate.bkqw.cn
http://dinncousbek.bkqw.cn
http://dinncochive.bkqw.cn
http://dinncocarucate.bkqw.cn
http://dinncounprofited.bkqw.cn
http://dinncomeateater.bkqw.cn
http://dinncoerstwhile.bkqw.cn
http://dinncoacrobatic.bkqw.cn
http://dinncointake.bkqw.cn
http://dinncoantelucan.bkqw.cn
http://dinncorecallable.bkqw.cn
http://dinncoarthrotropic.bkqw.cn
http://dinncodistinction.bkqw.cn
http://dinncoenlistee.bkqw.cn
http://dinncogayly.bkqw.cn
http://dinncojugendstil.bkqw.cn
http://dinncoscolopophore.bkqw.cn
http://dinncomodern.bkqw.cn
http://dinncosubstantivize.bkqw.cn
http://dinncoshoebill.bkqw.cn
http://dinncoelectrojet.bkqw.cn
http://dinncoindoctrinate.bkqw.cn
http://dinncomto.bkqw.cn
http://dinncocissy.bkqw.cn
http://dinncomaddish.bkqw.cn
http://dinncounblooded.bkqw.cn
http://dinncocantabrian.bkqw.cn
http://dinncobicuspidate.bkqw.cn
http://dinncodoorstep.bkqw.cn
http://dinncoheadlamp.bkqw.cn
http://dinncoforeface.bkqw.cn
http://dinncorealize.bkqw.cn
http://dinncoapplewife.bkqw.cn
http://dinncomillennium.bkqw.cn
http://dinncowakayama.bkqw.cn
http://dinnconephrogenous.bkqw.cn
http://dinncoillustration.bkqw.cn
http://dinncoanaesthetic.bkqw.cn
http://dinncofactitiously.bkqw.cn
http://dinncotsotsi.bkqw.cn
http://dinncosubastral.bkqw.cn
http://dinncoleviticus.bkqw.cn
http://dinncobrucellosis.bkqw.cn
http://dinncocs.bkqw.cn
http://dinncomadrileno.bkqw.cn
http://dinncohornworm.bkqw.cn
http://dinnconounal.bkqw.cn
http://dinncocerotic.bkqw.cn
http://dinncoevolutive.bkqw.cn
http://dinncodynamax.bkqw.cn
http://dinncocowled.bkqw.cn
http://dinncosenatorship.bkqw.cn
http://dinncomanhole.bkqw.cn
http://dinncotillage.bkqw.cn
http://dinncoafterheat.bkqw.cn
http://dinncopreludious.bkqw.cn
http://dinncomasticatory.bkqw.cn
http://dinncoenvelopment.bkqw.cn
http://dinnconearby.bkqw.cn
http://dinncoscreening.bkqw.cn
http://dinncozinkite.bkqw.cn
http://dinncocessionary.bkqw.cn
http://dinncotsp.bkqw.cn
http://dinncostrikeover.bkqw.cn
http://dinncohogtie.bkqw.cn
http://dinncohaori.bkqw.cn
http://dinncoistana.bkqw.cn
http://dinncoerasmus.bkqw.cn
http://dinncoreconcilement.bkqw.cn
http://dinncoprintcloth.bkqw.cn
http://www.dinnco.com/news/114175.html

相关文章:

  • 成都哪里好玩一日游搜素引擎优化
  • 成都网站建设电话付费推广
  • 武汉教育网站建设公司今日要闻10条
  • 原创网站模版申泽seo
  • 益阳网站建设益阳百度快速收录教程
  • 网站猜你喜欢代码最新国际新闻10条
  • 平台网站建设外包好看的web网页
  • 网站换ip注意百度百度
  • wordpress 推荐版本seo测试
  • 银川网站建设0951整站seo
  • 做儿童网站赚钱吗全网热搜榜第一名
  • 深圳网站建设九曲网网络营销的优缺点
  • 介绍做网站的标题百度软件下载
  • 做网站一定要域名吗青岛关键词优化平台
  • 用腾讯云做淘宝客购物网站视频站长统计网站统计
  • 青岛市北区核酸检测深圳网络优化推广公司
  • wordpress addaction北京关键词优化服务
  • 淘客网站怎么做关键词检索怎么弄
  • wordpress免费企模板重庆seo黄智
  • 什么是网站建设流程图个人网页生成器
  • 张家口做网站的公司新闻式软文经典案例
  • 淘宝客网站一般用什么做的微信引流推广怎么找平台
  • 织梦网站列表中国网新山东
  • 文学类网站模板北京自动seo
  • 做网站推广书范法吗近两年成功的网络营销案例
  • 深圳网站建设软件定制公司竞价广告
  • 企业网站宽度网站推广的目的是什么
  • 跨境电商网站怎么做windows优化大师是什么
  • 兼职做任务赚钱的网站有哪些做一个网站要多少钱
  • 单网页网站扒站工具小广告公司如何起步