美文网首页
样式(8) -- checkbox8

样式(8) -- checkbox8

作者: 卡拉咖啦 | 来源:发表于2019-10-24 01:01 被阅读0次

preview

demo预览

checkbox8

description

1.可调节数据:

$checkboxSize: 3em;
$checkboxWidthTimes: 3;
$checkboxFontSizeTimes: 0.6;
$checkboxFontSize: $checkboxSize * $checkboxFontSizeTimes;
$checkboxWidth: $checkboxSize * $checkboxWidthTimes;
$checkboxBackgroundColorForOFF: tomato;
$checkboxBackgroundColorForON: limegreen;
$checkboxTextForOFF: "OFF";
$checkboxTextForON: "ON";
$toggleSpeed: 0.3s;

2.详细描述

transform-origin 用于定义 transform 行为的原点(中心),可以传三个参数,分别是 x 偏移量,y 偏移量,z 偏移量
x 偏移量 / y 偏移量 可以是 length 或 percentage (百分比)
z 偏移量只能是 length
默认情况下,三个偏移量的值是:50% 50% 0;
还可以用 top / center / bottom 表示 y 偏移 0,50%,100%; left / center / right 表示 z 偏移 0,50%,100%;
在使用 top …… right 之类的时候,x / y 偏移量的参数位置可以交互。

transform-origin 可以跟 1 ~ 3 个值,后面的值取用默认值。

scss

/* html
<div class="checkboxWrapper">
    <input type="checkbox" value="" id="myCheckbox" name="slide" checked>
    <label for="myCheckbox">
      <div class="flipCard"></div>
    </label>
</div>
*/

* { padding: 0; margin: 0; box-sizing: border-box; }
*::before, *::after{ box-sizing: border-box; }

body {
  margin: 60px;
  background-color: #eee;
}

$checkboxSize: 2em;
$checkboxWidthTimes: 3;
$checkboxFontSizeTimes: 0.6;
$checkboxFontSize: $checkboxSize * $checkboxFontSizeTimes;
$checkboxWidth: $checkboxSize * $checkboxWidthTimes;
$checkboxBackgroundColorForOFF: tomato;
$checkboxBackgroundColorForON: limegreen;
$checkboxTextForOFF: "OFF";
$checkboxTextForON: "ON";
$toggleSpeed: 0.3s;


.checkboxWrapper {
  display: block;
  width: $checkboxWidth;
  height: $checkboxSize;
  line-height: $checkboxSize;

  & label{
    display: block;
    width: 100%;
    height: 100%;
    background-color: #fff;
    position: relative;
    perspective: 200px;

    & .flipCard, &::before, &::after {
      position: absolute;
      height: 100%;
      width:  50%;
      text-align: center;
    }

    &::before, &::after {
      content: $checkboxTextForON;
      font-size: $checkboxFontSize;
    }
    &::before {
      left: 0;
    }
    &::after {
      right: 0;
      content: $checkboxTextForOFF;
    }

    & .flipCard {
      left: 50%;
      display: block;
      background-color: $checkboxBackgroundColorForOFF;
      transition: all $toggleSpeed ease;
      z-index: 1;
      transform: rotateY(-180deg);
      transform-origin: center left;
      transform-style:preserve-3d;
    }
  }

  & input {
    display: none;

    &:checked + label .flipCard {
      background-color: $checkboxBackgroundColorForON;
      transform: rotateY(0deg);
    }
  }
}

素材参考:https://codepen.io/bennettfeely/pen/LKjmA

相关文章

  • 样式(8) -- checkbox8

    preview demo预览 description 1.可调节数据: 2.详细描述 transform-orig...

  • 8种复古风格字体Photoshop样式包

    今天小编为您带来的是8种复古风格字体Photoshop样式包,这是一个包含8种不同复古效果的样式,而且所有图层样式...

  • 大连滕泰科技学习笔记2020-08-21

    项目组8 1,1 CSS的定义层叠样式表 1,2 CSS的三种引入方式行内样式-- 内嵌样式-- 引入样式-...

  • 7. HTML——使用CSS样式

    样式介绍8.css样式的使用方式.png 样式说明(1)内链样式表: 他的使用方式是在标记的后面添加style="...

  • CSS笔记3:样式属性

    7. 尺寸样式属性 8. 文本属性 9. 字体属性 10. 列表样式属性 例如:

  • ajax在ie8下看不到请求

    背景: 由于平台要求兼容ie8,开发完成后想着在ie8上看看样式有没有变化,结果样式没问题,但是onmouseov...

  • 获取style的兼容方法

    获取或设置行间样式 oDiv.style.width 获取行间/内联/外部样式,无法设置 IE6-8 : oDiv...

  • 8 CSS常见样式

    块级元素和行内元素分别有哪些?动手测试并列出4条以上的特性区别 块级元素: 联系方式信息。 HTML5文章内容。...

  • AlertDialog基本使用

    1,默认样式 2,两个按钮样式 3,三个按钮样式 4,列表选择 5,单选列表 6,多选列表 7,使用适配器 8,自...

  • css+div布局页面,要注意的几个问题

    清除格式 写页面样式的时候先清除浏览器原有的标签默认样式:(例如如默认的body样式里面默认自带8像素的边框) 定...

网友评论

      本文标题:样式(8) -- checkbox8

      本文链接:https://www.haomeiwen.com/subject/btycvctx.html