xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

css border-radius & yin-yang & taiji

css border-radius & yin-yang & taiji

solution

css border-radius & tabs effect

https://codepen.io/xgqfrms/full/ZEbyMyz

@charset "UTF-8";

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

.box{
  width: 100vw;
  height: auto;
  min-height: 100px;
  display: flex;
  flex-wrap: nowrap;
  flex-flow: row;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #ccc;
  padding: 0;
}

.item {
  width: 50%;
  height: 100px;
  line-height: 100px;
  text-align: center;
}

.item-selected{
  background: #000;
}

.item-unselected{
  background: #fff;
}


.item-left{
  border-radius: 0 25px 0 0;
  -webkit-border-radius: 0 25px 0 0;
  -moz-border-radius: 0 25px 0 0;
  -ms-border-radius: 0 25px 0 0;
  -o-border-radius: 0 25px 0 0;
  position: relative;
}

.item-right{
  border-radius: 0 0 0 25px;
  -webkit-border-radius: 0 0 0 25px;
  -moz-border-radius: 0 0 0 25px;
  -ms-border-radius: 0 0 0 25px;
  -o-border-radius: 0 0 0 25px;
  position: relative;
}

.item-unselected .item-left,
.item-unselected .item-right {
  color: #fff;
  background: #000;
}

.item-selected .item-left,
.item-selected .item-right {
  color: #000;
  background: #fff;
}


  <section>
      <div class="box">
        <div class="item item-selected">
          <div class="item-left">VIP</div>
        </div>
        <div class="item item-unselected">
          <div class="item-right">Others</div>
        </div>
      </div>
  </section>

"use strict";

/**
 *
 * @author xgqfrms
 * @license MIT
 * @copyright xgqfrms
 * @created 2020-04-28
 * @modified
 *
 * @description css border-radius
 * @augments
 * @example
 * @link
 *
 */

const log = console.log;

const items = [...document.querySelectorAll(`.item`)];

const updateSelected = (items, selectedItem) => {
  items.forEach(item => {
    item.classList.remove(`item-selected`);
    item.classList.add(`item-unselected`)
  });
  selectedItem.classList.remove(`item-unselected`);
  selectedItem.classList.add(`item-selected`)
}

for (const item of items) {
  const flag = item.dataset.flag || false;
  if(!flag) {
    item.dataset.flag = true;
    item.addEventListener(`click`, (e) => {
      const className = e.target.getAttribute(`class`);
      switch (className) {
        case `item-left`:
        case `item-right`:
          updateSelected(items, e.target.parentElement);
          break;

        default:
          break;
      }
    });
  }
}



refs

https://www.w3schools.com/css/css3_borders.asp

https://css-tricks.com/almanac/properties/b/border-radius/


css yin-yang

https://codepen.io/xgqfrms/pen/VwvWdzV

https://coursesweb.net/css/yin-yang-css_cs

https://blog.logrocket.com/how-to-create-yin-yang-symbol-pure-css/

https://css-tricks.com/creating-yin-yang-loaders-web/

https://gist.github.com/felipecabargas/6574545


posted @   xgqfrms  阅读(218)  评论(1编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2019-04-28 React Native & Android & iOS & APK
2019-04-28 React Navigation & React Native & React Native Navigation
2019-04-28 React Native & app demos
点击右上角即可分享
微信分享提示