@Flipzy
Веб-разработчик

Как починить чекбоксы и правильно их расположить относительно текста?

Есть маакет
spoiler
634973179606b104057902.png
вот результат, который получился у меня
spoiler
63497339c71bd682022260.png
Работает только первый чекбокс, а остальные нет. Как это поправить и спозиционировать чекбоксы относительно текста?
html
<div class="intrests-choose">
                    <form action="" class="intrests-form">
                        <div class="form-item">
                            <input type="checkbox" class="intrests-checkbox" id="investing" name="investing">
                            <label for="investing">
                                <h3 class="checkbox-title">Investing</h3>
                                <p class="checkbox-text">Hanvesting will guide you every step of the way so you can master the courses and make it work for your milestones.</p>
                            </label>
                        </div>
                        <div class="form-item">
                            <input type="checkbox" class="intrests-checkbox" id="investing" name="finance">
                            <label for="finance">
                                <h3 class="checkbox-title">Finance</h3>
                                <p class="checkbox-text">Hanvesting will guide you every step of the way so you can master the courses and make it work for your milestones.</p>
                            </label> 
                        </div>
                        <div class="form-item">
                            <input type="checkbox" class="intrests-checkbox" id="investing" name="econmy">
                            <label for="economy">
                                <h3 class="checkbox-title">Economy</h3>
                                <p class="checkbox-text">Hanvesting will guide you every step of the way so you can master the courses and make it work for your milestones.</p>
                            </label>
                        </div>
                        <div class="form-item">
                            <input type="checkbox" class="intrests-checkbox" id="investing" name="data analysis">
                            <label for="data analysis">
                                <h3 class="checkbox-title">Data Analysis</h3>
                                <p class="checkbox-text">Hanvesting will guide you every step of the way so you can master the courses and make it work for your milestones.</p>
                            </label>
                        </div>
                        <div class="form-item">
                            <input type="checkbox" class="intrests-checkbox" id="investing" name="trading">
                            <label for="trading">
                                <h3 class="checkbox-title">Trading</h3>
                                <p class="checkbox-text">Hanvesting will guide you every step of the way so you can master the courses and make it work for your milestones.</p>
                            </label>
                        </div>
                        <div class="form-item">
                            <input type="checkbox" class="intrests-checkbox" id="investing" name="scaling">
                            <label for="scaling">
                                <h3 class="checkbox-title">Scaling</h3>
                                <p class="checkbox-text">Hanvesting will guide you every step of the way so you can master the courses and make it work for your milestones.</p>
                            </label>
                        </div> 
                    </form>
                </div>

css
.intrests {
    background: url("./img/intrest-bg.png");
    background-size: cover;
}

.intrests-form {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
}

.itrests-title {
    padding-top: 175px;
    font-size: 70px;
    font-family: "Karla";
    color: rgb(237, 229, 218);
    font-weight: 700;
    line-height: 1;
    text-align: center;
}  

.intrests-suptitle {
    display: block;
    font-size: 15px;
    font-family: "Karla";
    color: rgb(237, 229, 218);
    line-height: 1.2;
    text-align: center;
    margin: 0 auto;
    max-width: 360px;
    margin-top: 10px;
}

.intrests-checkbox {
    background: none;
    border: 2px solid #223974;
}

.form-item {
    display: flex;
}

.intrests-choose {
    margin-top: 80px;
    padding-bottom: 180px;
}

.checkbox-title {
    position: relative;
    font-size: 23px;
    font-family: "Karla";
    color: rgb(49, 87, 173);
    font-weight: 700;
    text-align: left;
    margin-bottom: 15px;
    margin-left: 25px;
}

.checkbox-text {
    position: relative;
    font-size: 15px;
    font-family: "Karla";
    color: rgb(233, 227, 217);
    text-align: left;
    max-width: 265px;
    margin-left: 25px;
}

.intrests-checkbox {
    position: absolute;
    z-index: -1;
    opacity: 0;
}

.intrests-checkbox+label::before {
    content: '';
    display: inline-block;
    width: 37px;
    height: 38px;
    flex-shrink: 0;
    flex-grow: 0;
    border: 2px solid #243e79;
    border-radius: 10px;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 50% 50%;
}

.intrests-checkbox:checked+label::before {
    border-color: #0b76ef;
    background-color: #0b76ef;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23fff' d='M6.564.75l-3.59 3.612-1.538-1.55L0 4.26 2.974 7.25 8 2.193z'/%3e%3c/svg%3e");
}
  • Вопрос задан
  • 54 просмотра
Пригласить эксперта
Ответы на вопрос 1
Fragster
@Fragster
помогло? отметь решением!
Сделать лабел гридом 2*2, внутрь положить три элемента: 1: чекбокс + псевдоэлемент (перецепить его от лабела), 2: жирную надпись, 3: мелкую надпись. у мелкой надписи прибить колонку номер два через grid-column-start: 2;
что-то типа такого: https://codepen.io/FragsterAt/pen/xxjBZPW
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы