mardi 12 décembre 2017

Align label contents after checkbox css

I have styled Checkbox from this source as below:

.toggle-button {
    margin: 0 20px;
}


/*
   * Toggle button styles
   */

.toggle-button {
    position: relative;
    display: inline-block;
    color: rgb(80, 77, 77);
}

.toggle-button label {
    display: inline-block;
    cursor: pointer;
    text-align: left;
}

.toggle-button input {
    display: none;
}

.toggle-button__icon {
    cursor: pointer;
    pointer-events: none;
}

.toggle-button__icon:before,
.toggle-button__icon:after {
    content: "";
    position: absolute;
    top: 45%;
    left: 35%;
    transition: 0.2s ease-out;
}

.toggle-button--tuli label {
    line-height: 20px;
    text-indent: 30px;
}

.toggle-button--tuli input[type=checkbox]:checked~.toggle-button__icon {
    background: #fff;
}

.toggle-button--tuli input[type=checkbox]:checked~.toggle-button__icon:before,
.toggle-button--tuli input[type=checkbox]:checked~.toggle-button__icon:after {
    opacity: 1;
}

.toggle-button--tuli .toggle-button__icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    transition: all 0.2s;
    border: 2px solid rgb(37, 146, 236);
    border-radius: 1px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
}

.toggle-button--tuli .toggle-button__icon:before,
.toggle-button--tuli .toggle-button__icon:after {
    top: 5px;
    left: 2px;
    width: 12px;
    height: 2px;
    border-radius: 3px;
    background: #fff;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
    top: 35%;
    background: #0175b2;
    opacity: 0;
    transform-origin: left center;
}

.toggle-button--tuli .toggle-button__icon:before {
    transform: translate(0, 0) rotate(45deg) scale(0.6, 1);
}

.toggle-button--tuli .toggle-button__icon:after {
    transform: translate(4px, 6px) rotate(-45deg);
}

.toggle-button--tuli:hover input[type=checkbox]:not(:checked)~.toggle-button__icon {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
<link href="http://ift.tt/2apRjw3" rel="stylesheet" />
<script src="http://ift.tt/1oMJErh"></script>
<script src="http://ift.tt/2aHTozy"></script>


<div class="toggle-button toggle-button--tuli">
  <input id="toggleButton11" type="checkbox">
  <label for="toggleButton11">I confirm that I have read and agree to the <a href="#" style="color:#2c6ed7">Terms of Use</a> specified by the client and some long text to continue with to show the alignment below checkbox</label>
  <div class="toggle-button__icon"></div>
</div>

If you run the snippet you can see that when label contents break the line it comes below the checkbox. How can I modify the css to align label contents to appear after the checkbox. I've tried text-indent but that only works for 1st line. Hope to find some help.




Aucun commentaire:

Enregistrer un commentaire