未分類

ページ遷移式アンケート(ボタンデザイン|複数選択)※要javascript(アンケート)

  • Q1
  • Q2
  • Q3

Q1借入金額を教えてください

1/3

下記Beyondコード

JS head


<script>
    var checkInputState = checkInputState || {};
    (function(_) {
        const target = '.js-check-input';

        _.checkInputs = function(el) {
            var max = el.dataset.max || 0;
            var link = el.querySelector('.js-check-input-link');
            if (link) link.classList.add('disabled');
            var inputs = el.querySelectorAll('input[type=checkbox]');
            el.addEventListener('change', function(e) {
                var checkedNum = el.querySelectorAll('input[type=checkbox]:checked').length;
                if (max > 0) {
                    if (checkedNum >= max) {
                        inputs.forEach((input) => {
                            if (!input.checked) input.disabled = true;
                        })
                    } else {
                        inputs.forEach((input) => {
                            input.disabled = false;
                        })
                    }
                }
                if (link && checkedNum > 0) {
                    link.classList.remove('disabled');
                } else {
                    link.classList.add('disabled');
                }
            })
        };

        _.init = function() {
            Array.from(document.querySelectorAll(target), el => {
                _.checkInputs(el);
            });
        };


    })(checkInputState);
</script>


<script>
    document.addEventListener('DOMContentLoaded', checkInputState.init, false);
</script>

HTML



<div class="l-quizBox js-check-input" data-max="2">
    <div class="quiz_cont_wrap">
        <ul class="flow-list">
            <li class="flow-list_item current">Q1</li>
            <li class="flow-list_item">Q2</li>
            <li class="flow-list_item">Q3</li>

        </ul>
        <div class="quiz_cont">
            <div class="quiz_cont_item">
                <p class="quiz_cont_ttl"><span class="q_mark">Q1</span>借入金額を教えてください</p>

                <ul class="quiz_cont_select">
                    <li class="quiz_cont_select_item"><label><input type="checkbox"><span>0~49万円</span></label></li>
                    <li class="quiz_cont_select_item"><label><input type="checkbox"><span>テキストが入ります</span></label></li>
                    <li class="quiz_cont_select_item"><label><input type="checkbox"><span>テキストが入ります</span></label></li>

                </ul>
                <div class="wrap-btn-forword"><a href="ooooo" class="btn-forword js-check-input-link" draggable="false">次に進む</a></div>
                <p class="quiz_cont_progress"><span>1</span>/3</p>
            </div>
        </div>
    </div>
</div>

CSS


 .l-quizBox {
  background: #87cefa;
  margin: 0 auto 20px;
  width: 100%;
}

 .quiz_cont_wrap {
  max-width: 750px;
  width: 100%;
  margin: 0 auto;
  padding: 0 3% 30px;
  box-sizing: border-box;
}

 .flow-list {
  max-width: 564px;
  padding: 8px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  list-style-type: none;
  margin: 0 auto;
}

 .flow-list_item {
  height: 52px;
  background: #fff;
  font-size: 24px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  position: relative;
}

@media screen and (max-width: 767px) {
   .flow-list_item {
    font-size: 18px;
  }
}

 .flow-list_item.current {
  background: #9ae5e8;
}

 .flow-list_item:not(:last-of-type) {
  border-right: 1px solid #dedede;
}

 .flow-list_item:before {
  content: "";
  position: absolute;
  right: -9px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7.5px 0 7.5px 10px;
  border-color: transparent transparent transparent #fff;
  z-index: 2;
  margin: 0;
}

 .flow-list_item:after {
  content: "";
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 8px 0 8px 11.5px;
  border-color: transparent transparent transparent #dedede;
  z-index: 1;
}

 .flow-list_item.current::before {
  border-color: transparent transparent transparent #9ae5e8;
}

 .flow-list_item:last-of-type.current:before {
  border-color: transparent transparent transparent #fff;
}

 .flow-list_item:last-of-type::before,
 .flow-list_item:last-of-type::after,
 .flow-list_item:last-of-type.current::before,
 .flow-list_item:last-of-type.current::after {
  content: none;
}

 .quiz_cont {
  padding: 10px 0 5%;
  background: #fff;
  border-radius: 20px;
  margin: 0;
}

 .quiz_cont .quiz_cont_ttl {
  font-size: 34px;
  font-weight: bold;
  color: #594313;
  margin: 10px 0;
  display: flex;
  align-items: center;
}

@media screen and (max-width: 767px) {
   .quiz_cont .quiz_cont_ttl {
    font-size: 26px;
  }
}

 .quiz_cont .quiz_cont_ttl span {
  background: #00008b;
  color: #fff;
  font-size: 40px;
  padding: 0 20px;
  height: 140px;
  margin-right: 100px;
  box-sizing: border-box;
  position: relative;
  display: flex;
  align-items: center;
}

@media screen and (max-width: 767px) {
   .quiz_cont .quiz_cont_ttl span {
    font-size: 30px;
    height: 90px;
    margin-right: 30px;
    padding: 0 10px;
  }
}

 .quiz_cont .quiz_cont_ttl span:before {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 70px 0 70px 20px;
  border-color: transparent transparent transparent #00008b;
  right: -20px;
  top: 0;
}

@media screen and (max-width: 767px) {
   .quiz_cont .quiz_cont_ttl span:before {
    border-width: 45px 0 45px 15px;
    right: -14.5px;
  }
}

 .quiz_cont .quiz_cont_image {
  padding: 0 20px;
  margin: 0;
}

 .quiz_cont .quiz_cont_image img {
  max-width: 100%;
  height: auto;
}

 .quiz_cont_select {
  width: 94%;
  margin: 20px auto 0;
  padding: 0;
  list-style-type: none;
}

 .quiz_cont_select_item {
  margin: 30 10 50 10;
}

 .quiz_cont_select_item:not(:last-of-type) {
  margin-bottom: 16px;
}

 .quiz_cont_select_item input {
  display: none;
}

 .quiz_cont_select_item label span,
 .quiz_cont_select_item a {
  width: 100%;
  padding: 15px 10px;
  background:#fedddd;
  color: #000000;
  font-weight: bold;
  font-size: 24px;
  border-radius: 50px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
}

@media screen and (max-width: 767px) {

   .quiz_cont_select_item label span,
   .quiz_cont_select_item a {
    font-size: 24px;
  }
}

 .quiz_cont_select_item input[type="checkbox"]:checked+span {
  box-shadow: 0 0 0 2px #fff, 0 0 0 6px #e2041b;
}

 .quiz_cont_select_item input[type="checkbox"]:disabled+span {
  background: linear-gradient(#e0e0e0, #a0a0a0);
  color: #ffffff;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #a0a0a0;
}

 .wrap-btn-forword {
  text-align: center;
  width: 100%;
  margin: 20px 0;
}

 .btn-forword {
  width: 80%;
  margin: 0 auto;
  padding: 10px;
  line-height: 1.2;
  display: inline-block;
  font-size: 26px;
  font-weight: bold;
  border-radius: 24px;
  color: #000000;
  border: none;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #006400;
  background-color: #008000;
  cursor: pointer;
  box-sizing: border-box;
  text-decoration: none;
}

 .btn-forword.disabled {
  pointer-events: none;
  background-color: #ccc;
  color: #666;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #666;
}

 .quiz_cont_progress {
  color: #594313;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  margin: 0;
  margin-top: 26px;
}

 .quiz_cont_progress span {
  font-size: 34px;
}

 .quiz_cont_image img {
  max-width: 100%;
}