css+js实现泡泡ui布局效果代码

代码语言:html

所属分类:布局界面

代码描述:css+js实现泡泡ui布局效果代码

代码标签: css js 泡泡 ui 布局

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

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
<style>
    .Container {
  display: grid;
  gap: 1rem;
  padding: 3rem 4rem;
  border-radius: 0.5rem;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
}
@media (min-width: 712px) {
  .Container {
    grid-template-columns: repeat(2, clamp(20vw, 20rem, 50vw));
  }
}

/* ----------------
    Global input
   ---------------- */
.Toggle input[type=checkbox],
.Radio input[type=radio] {
  position: absolute;
  left: -100vw;
}

.Toggle input[type=checkbox] + label,
.Radio input[type=radio] + label {
  position: relative;
  display: block;
  line-height: 3rem;
  cursor: pointer;
  white-space: nowrap;
}

.Toggle input[type=checkbox] + label::before,
.Toggle input[type=checkbox] + label::after,
.Radio input[type=radio] + label::before,
.Radio input[type=radio] + label::after {
  content: "";
  display: inline-block;
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  transition: 0.5s;
}

/* large */
.Toggle__large input[type=checkbox] + label,
.Radio__large input[type=radio] + label,
.Range__large input[type=range] + label {
  font-size: 2rem;
  line-height: 6rem;
}

/* ----------------
    Range input
   ---------------- */
.Range {
  display: flex;
  flex-direction: column-reverse;
  margin-bottom: 1rem;
}

.Range input[type=range] + label {
  display: block;
  line-height: 1.3;
  margin-bottom: 0.3rem;
}

.Range input[type=range] {
  appearance: none;
  height: 2rem;
  border-radius: 1rem;
  padding: 0.5rem;
  background: #eee;
}

.Range input[type=range]::-webkit-slider-thumb {
  appearance: none;
  width: 1.4rem;
  height: 1.4rem;
  cursor: pointer;
  transition: 0.5s;
  transition-timing-function: cubic-bezier(0.73, 2, 0.25, -0.7);
}

.Range input[type=range]::-moz-range-thumb {
  appearance: none;
  width: 1.4rem;
  height: 1.4rem;
  cursor: pointer;
  transition: 0.5s;
}

.Range input[type=range]:active::-webkit-slider-thumb {
  transition-timing-function: linear;
  transform: scale(1.3, 0.7);
}

.Range input[type=range]:active::-moz-range-thumb {
  animation: none;
  transform: scale(1.3, 0.7);
}

@media (min-width: 712px) {
  .Range_row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
  }
  .Range_row .Range {
    width: calc(50% - .5rem);
    margin-bottom: 0;
  }
}

/* Toggle large */
.Range__large input[type=range] {
  height: 4rem;
  border-radius: 2rem;
}

.Range__large input[type=range]::-webkit-slider-thumb {
  width: 3rem;
  height: 3rem;
}

.Range__large input[type=range]::-moz-range-thumb {
  width: 3rem;
  height: 3rem;
}

/* ----------------
    Toggles input
   ---------------- */
.Toggle input[type=checkbox] + label {
  padding-left: 5rem;
}

.Toggle input[type=checkbox] + label::before {
  width: 4rem;
  aspect-ratio: 2/1;
  border-radius: 1rem;
  background: #eee;
}

.Toggle input[type=checkbox]:checked + label::before {
  background: #ddf8eb;
}

.Toggle input[type=checkbox] + label::after {
  left: 0.25rem;
  width: 1.4rem;
}

.Toggle input[type=checkbox]:checked + label::after {
  animation: toggle 0.5s linear;
  transform: translate(125%, -50%);
}

/* Toggle large */
.Toggle__large input[type=checkbox] + label {
  padding-left: 9rem;
}

.Toggle__large input[type=checkbox] + label::before {
  width: 8rem;
  border-radius: 2rem;
}

.Toggle__large input[type=checkbox] + label::after {
  left: 0.5rem;
  width: 3rem;
}

/* ----------------
    Radio input
   ---------------- */
.Radio input[type=radio] + label {
  padding-left: 3rem;
}

.Radio input[type=radio] + label::before {
  width: 2rem;
  aspect-ratio: 1/1;
  border-radius: 50%;
  background: #eee;
}

.Radio input[type=radio] + label::after {
  left: 0.2rem;
  width: 1.4rem;
  transform: translateY(-50%) scale(0);
}

.Radio input[type=radio]:not(:checked) + label::after {
  animation: radio 0.5s linear;
}

.Radio input[type=radio]:checked + label::after {
  transform: translateY(-50%) scale(1);
}

/* Radio larg */
.Radio__large input[type=radio] + label {
  padding-left: 5rem;
}

.Radio__large input[type=radio] + label::before {
  width: 4rem;
}

.Radio__large input[type=radio] + label::after {
  left: 0.4rem;
  width: 3rem;
}

/* ----------------
    Bubble display
   ---------------- */
.Toggle input[type=checkbox] + label::after,
.Radio input[type=radio] + label::after,
.Range input[type=range]::-webkit-slider-thumb {
  aspect-ratio: 1/1;
  border: 0.1rem solid #fff;
  border-radius: 50%;
  background: radial-gradient(circle at 70% 30%, #fff, transparent 25%), radial-gradient(circle at 60% 55%, transparent 60%, rgba(255, 0, 255, 0.8) 100%), radial-gradient(circle at 50% 50%, transparent 40%, rgba(0.........完整代码请登录后点击上方下载按钮下载查看

网友评论0