radio美化点击选择效果

代码语言:html

所属分类:表单美化

代码描述:radio美化点击选择效果

代码标签: 选择 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
@import url("https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700;800&family=Barlow:wght@400;700&display=swap");
:root {
  --font-barlow: 'Barlow', sans-serif;
  --font-barlowCondensed: 'Barlow Condensed', sans-serif;
  --time-nav-hover: 0.25s;
  --color-fire: #E30000;
  --color-black: #191919;
  --color-grey-5: #FBFBFB;
  --color-grey-10: #F6F7F7;
  --color-grey-cool-10: #EEEEEF;
  --color-grey-15: #E8E8E8;
  --color-grey-20: #D5D6D8;
  --color-grey-60: #ABADB1;
  --color-grey-70: #888891;
  --color-grey-80: #6B6A6A;
  --color-grey-85: #59595F;
  --shadow-fire:
  	0 4px 12px 4px rgba(227,0,0,0.2),
  	0 1px 3px 0 rgba(137,7,7,0.4)
  ;
  --focus-style: dotted 2px var(--color-black);
  --focus-offset: 2px;
}

body {
  color: var(--color-black);
  font-family: var(--font-barlow);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

#inputContainer {
  height: 100vh;
  margin: 0 auto;
  max-width: 50em;
  padding: 2em;
  display: -webkit-box;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
          flex-flow: column;
  -webkit-box-pack: center;
          justify-content: center;
}

.inputGroup {
  display: block;
  margin: 0 0 1.5em;
}

.label {
  display: block;
  font-size: 1.5em;
  font-weight: 700;
  font-family: var(--font-barlowCondensed);
  line-height: 1.25em;
  margin: 0 0 .6em;
  padding: 0;
  text-transform: uppercase;
}

#aspectRatio--group {
  --options: 3;
  --options-active: 1;
  --options-gap: .5em;
}

.segmentedControl {
  background: var(--color-grey-10);
  border: solid 1px var(--color-grey-70);
  border-radius: 0.25em;
  position: relative;
  display: -webkit-box;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
          flex-flow: row;
  -webkit-box-pack: start;
          justify-content: flex-start;
}
.segmentedControl .segmentedControl--group {
  -webkit-box-flex: 0;
          flex: 0 0 auto;
  margin: var(--options-gap);
  width: calc((100% - ((var(--options)*var(--options-gap))*2)) / var(--options));
  display: -webkit-box;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
          flex-flow: row;
  -webkit-box-pack: stretch;
          justify-content: stretch;
  -webkit-box-align: stretch;
          align-items: stretch;
}
.segmentedControl .segmentedControl--group input {
  opacity: 0;
  position: absolute;
}
.segmentedControl .segmentedControl--group input + label {
  border-radius: .25em;
  -webkit-box-flex: 1;
          flex: 1 1 100%;
  font-size: 1.25em;
  font-weight: normal;
  font-family: var(--font-barlow);
  line-height: 1;
  margin: 0;
  padding: 0.5em 0;
  position: relative;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  z-index: 1;
}
.segmentedControl .segmentedControl--group input + label::before, .segmentedControl .segmentedControl--group input + label::after {
  border-radius: inherit;
  content: "";
  display: block;
  height: 100%;
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: -1;
}
.segmentedControl .segmentedControl--group input + label::before {
  background: var(--color-grey-20);
  -webkit-transition: opacity .15s ease;
  transition: opacity .15s ease;
}
.segmentedControl .segmentedControl--group input + label::after {
  background: var(--color-fire);
  box-shadow: var(--shadow-fire);
  -webkit-transition: opacity .15s ease;
  transition: opacity .15s ease;
}
.segmentedControl .segmentedControl--group input + label:hover::before {
  opacity: 1;
}
.segmentedControl .segmentedControl--group input:focus + label {
  outline: none;
}
.segmentedControl .segmentedControl--group input:focus-visible + label {
  outline: var(--focus-style);
  outline-offset: var(--focus-offset);
}
.segmentedControl .segmentedControl--group input:-moz-focusring + label {
  outline: var(--focus-style);
  outline-offset: var(--focus-offset);
}
.segmentedControl .segmentedControl--group input:checked + label {
  background: var(--color-grey-10);
  color: #fff;
  font-weight: 700;
}
.segmentedControl .segmentedControl--group input:checked + label::after {
  opacity: 1;
  -webkit-transform: scale(1);
          transform: scale(1);
}

@media (prefers-reduced-motion: no-preference) {
  .segmentedControl .segmentedControl--group input + label {
    -webkit-transition: color .2s ease;
    transition: color .2s e.........完整代码请登录后点击上方下载按钮下载查看

网友评论0