2022-03-17

How to show the button when at least one of the elements is active, and hide it when no element is selected?

I have twenty elements (input checkboxes) on the page. I need an object (button) to appear when clicking on any of the elements . But when no element is active, the object needs to disappear. Please help me to do this. I thought for a long time, but did not find a solution. Here is the HTML code for convenience:

.submit-btn {
  opacity: 0;
  position: absolute;
  left: 50%;
  top: 75%;
  transform: translate(-50%, 0);
  width: 147px;
  height: 52px;
  background: #fff;
  border: 3px solid #21ebff;
  box-sizing: border-box;
  border-radius: 30px;
  cursor: pointer;
  background: linear-gradient(to right, #21ebff 0%, #21ebff 50%, #ffffff 50%, #ffffff 100%);
  background-size: 200% 100%;
  background-position: 100% 0;
  transition: background-position 0.5s;
  transition: all 0.3s ease-in-out;
}

.submit-btn:hover {
  background-position: 0 0;
}

.arrow {
  display: inline-flex;
  position: relative;
  width: 0;
  height: 20px;
  cursor: pointer;
  margin-top: 5px;
}

.active {
  opacity: 1;
}

.arrow:before,
.arrow:after {
  display: inline-flex;
  position: absolute;
  content: '';
}

.arrow:before {
  top: 8px;
  right: -50px;
  width: 40px;
  height: 3px;
  background-color: #21ebff;
  transition: all 0.6s;
}

.arrow:after {
  width: 15px;
  height: 15px;
  top: 2px;
  right: -51px;
  border-top: 3px solid #21ebff;
  border-right: 3px solid #21ebff;
  transform: rotate(45deg);
  transition: all 0.5s;
}

.submit-btn:hover .arrow:before {
  background-color: #fff;
}

.submit-btn:hover .arrow:after {
  border-top: 3px solid #fff;
  border-right: 3px solid #fff;
}

.decades-checkbox-list {
  position: absolute;
  top: 35%;
  left: 50%;
  transition: all 2s;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
}

.decades-checkbox-col {
  display: flex;
  flex-direction: column;
  margin: 0 40px;
}

.decades-checkbox-item {
  width: 300px;
  margin: 15px 0;
  display: flex;
  align-items: center;
  user-select: none;
}

.decades-checkbox-item {
  width: 300px;
  margin: 15px 0;
  display: flex;
  align-items: center;
  user-select: none;
}

.decades-checkbox-input:checked+.decades-checkbox-span {
  border-color: #21ebff;
  box-shadow: 0px 0px 0px 15px #21ebff inset;
}

.decades-checkbox-input:checked+.decades-checkbox-span::after {
  opacity: 1;
  transform: scale(1);
}

.decades-checkbox-label {
  padding-left: 40px;
  word-spacing: 3px;
  font-family: 'Marvel';
  font-size: 26px;
  color: #202020;
  position: absolute;
  z-index: 10;
  cursor: pointer;
}

.decades-checkbox-span {
  width: 25px;
  height: 25px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  border-radius: 100px;
  background-color: #FFF;
  border: 3px solid #21ebff;
  box-shadow: 0px 0px 0px 0px #21ebff inset;
  transition: all 0.15s cubic-bezier(0, 1.05, 0.72, 1.07);
}

.decades-checkbox-span::after {
  content: '';
  width: 100%;
  height: 100%;
  opacity: 0;
  z-index: 4;
  position: absolute;
  transform: scale(0);
  background-size: 50%;
  background-image: url('https://s6.picofile.com/d/8392306668/bacc888c-bed7-41a9-bf24-f6ff0718f471/checkmark.svg');
  background-repeat: no-repeat;
  background-position: center;
  transition-delay: 0.2s !important;
  transition: all 0.25s cubic-bezier(0, 1.05, 0.72, 1.07);
}
<ul class="decades-checkbox-list">
  <div class="decades-checkbox-col">
    <li class="decades-checkbox-item">
      <input class="decades-checkbox-input" type="checkbox" id="decadesCboxInput-1" onclick="disableFunc()">
      <span class="decades-checkbox-span"></span>
      <label class="decades-checkbox-label" for="decadesCboxInput-1">The 1930s</label>
    </li>
    <li class="decades-checkbox-item">
      <input class="decades-checkbox-input" type="checkbox" id="decadesCboxInput-2" onclick="disableFunc()">
      <span class="decades-checkbox-span"></span>
      <label class="decades-checkbox-label" for="decadesCboxInput-2">The 1940s</label>
    </li>
    <li class="decades-checkbox-item">
      <input class="decades-checkbox-input" type="checkbox" id="decadesCboxInput-3" onclick="disableFunc()">
      <span class="decades-checkbox-span"></span>
      <label class="decades-checkbox-label" for="decadesCboxInput-3">The 1950s</label>
    </li>
    <li class="decades-checkbox-item">
      <input class="decades-checkbox-input" type="checkbox" id="decadesCboxInput-4" onclick="disableFunc()">
      <span class="decades-checkbox-span"></span>
      <label class="decades-checkbox-label" for="decadesCboxInput-4">The 1960s</label>
    </li>
    <li class="decades-checkbox-item">
      <input class="decades-checkbox-input" type="checkbox" id="decadesCboxInput-5" onclick="disableFunc()">
      <span class="decades-checkbox-span"></span>
      <label class="decades-checkbox-label" for="decadesCboxInput-5">The 1970s</label>
    </li>
  </div>
  <div class="decades-checkbox-col">
    <li class="decades-checkbox-item">
      <input class="decades-checkbox-input" type="checkbox" id="decadesCboxInput-6" onclick="disableFunc()">
      <span class="decades-checkbox-span"></span>
      <label class="decades-checkbox-label" for="decadesCboxInput-6">The 1980s</label>
    </li>
    <li class="decades-checkbox-item">
      <input class="decades-checkbox-input" type="checkbox" id="decadesCboxInput-7" onclick="disableFunc()">
      <span class="decades-checkbox-span"></span>
      <label class="decades-checkbox-label" for="decadesCboxInput-7">The 1990s</label>
    </li>
    <li class="decades-checkbox-item">
      <input class="decades-checkbox-input" type="checkbox" id="decadesCboxInput-8" onclick="disableFunc()">
      <span class="decades-checkbox-span"></span>
      <label class="decades-checkbox-label" for="decadesCboxInput-8">The 2000s</label>
    </li>
    <li class="decades-checkbox-item">
      <input class="decades-checkbox-input" type="checkbox" id="decadesCboxInput-9" onclick="disableFunc()">
      <span class="decades-checkbox-span"></span>
      <label class="decades-checkbox-label" for="decadesCboxInput-9">The 2010s</label>
    </li>
    <li class="decades-checkbox-item">
      <input class="decades-checkbox-input" type="checkbox" id="decadesCboxInput-10" onclick="disableFunc()">
      <span class="decades-checkbox-span"></span>
      <label class="decades-checkbox-label" for="decadesCboxInput-10">The 2020s</label>
    </li>
  </div>
</ul>


No comments:

Post a Comment