Home > database >  How to move text from inside the checkbox/label
How to move text from inside the checkbox/label

Time:12-20

My problem is, they overlap each other: https://i.stack.imgur.com/ltZ8w.png

I need to do like this: https://i.stack.imgur.com/roBun.png

What can I do? I just need to line text with my input checkbox, as I showed in my picture, any suggestions?

.round {
    position: relative;
    margin-left: 50px;
}

.round label {
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    cursor: pointer;
    height: 28px;
    left: 0;
    position: absolute;
    top: 0;
    width: 28px;
}

.round label:after {
    border: 2px solid #fff;
    border-top: none;
    border-right: none;
    content: "";
    height: 6px;
    left: 7px;
    opacity: 0;
    position: absolute;
    top: 8px;
    transform: rotate(-45deg);
    width: 12px;
}

.round input[type="checkbox"] {
    visibility: hidden;
}

.round input[type="checkbox"]:checked label {
    background-color: #66bb6a;
    border-color: #66bb6a;
    text-decoration: line-through;
    color: #3CC070;
}

.tasks input[type="checkbox"]:checked label {
    border-color: #66bb6a;
    text-decoration: line-through;
    color: #3CC070;
}

.round input[type="checkbox"]:checked label:after {
    opacity: 1;
}
                <div>
                    <div> <input type="checkbox"  checked>
                        <label>Make some cash</label>
                    </div>
                    <div >
                        <input type="checkbox" id="checkbox" />
                        <label for="checkbox" > Make</label>
                    </div>
                </div>

CodePudding user response:

you can add pseudo Before for label and add text inside it.

remove label content <label for="checkbox" ></label>

    label.text:before {
    content: "click";
    display: inline-block;
    left: 37px;
    position: absolute;
    top: 4px;
}

.round {
    position: relative;
    margin-left: 50px;
}

.round label {
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 50%;
    cursor: pointer;
    height: 28px;
    left: 0;
    position: absolute;
    top: 0;
    width: 28px;
}

label.text:before {
   content: "click";
   display: inline-block;
   left: 37px;
   position: absolute;
   top: 4px;
}
.round label:after {
    border: 2px solid #fff;
    border-top: none;
    border-right: none;
    content: "";
    height: 6px;
    left: 7px;
    opacity: 0;
    position: absolute;
    top: 8px;
    transform: rotate(-45deg);
    width: 12px;
}

.round input[type="checkbox"] {
    visibility: hidden;
}

.round input[type="checkbox"]:checked label {
    background-color: #66bb6a;
    border-color: #66bb6a;
    text-decoration: line-through;
    color: #3CC070;
}

.tasks input[type="checkbox"]:checked label {
    border-color: #66bb6a;
    text-decoration: line-through;
    color: #3CC070;
}

.round input[type="checkbox"]:checked label:after {
    opacity: 1;
}
                <div>
                    <div> <input type="checkbox"  checked>
                        <label>Make some cash</label>
                    </div>
                    <div >
                        <input type="checkbox" id="checkbox" />
                        <label for="checkbox" ></label>
                    </div>
                </div>

  • Related