TYPO3 表单 - Bootstrap 复选框样式

TYPO3 form - Bootstrap styling of checkboxes

是否有现成的 css 片段来设置使用 TYPO3 扩展表单 (https://docs.typo3.org/typo3cms/extensions/form/8.7/) 创建的复选框的样式?表单复选框元素的 html 如下所示:

html:

<div class="form-group">
    <div class="input checkbox">
        <div class="form-check">
            <label class="add-on form-check-label" for="basicContactForm-checkbox-1">
            <input name="tx_form_formframework[BasicContactForm][checkbox-1]" value="" type="hidden">
            <input required="required" class="add-on" id="basicContactForm-checkbox-1" name="tx_form_formframework[BasicContactForm][checkbox-1]" value="1" type="checkbox">
            <span>Yes, I confirm!<span class="required">*</span></span>
            </label>
        </div>
    </div>
</div>

我想将它设计成类似的样式,例如太棒了 Bootstrap 复选框:

https://www.cssscript.com/demo/pretty-checkbox-radio-inputs-with-bootstrap-and-awesome-bootstrap-checkbox-css/

完成此任务的最佳方法是什么?

只需将 CSS 添加到您的头部并按照 github https://github.com/flatlogic/awesome-bootstrap-checkbox

上的文档进行操作

像这样的东西会起作用

为您的 html 添加了跨度 - 请参阅下面的注释 剩下的只是 css - 我希望这对你有帮助

如果你不能添加任何 html 并且它必须是直的 css 那么这个 fiddle 就可以了(我能做到最好)。扩展这个 css 应该可以解决问题

.form-check {
    display: block;
    position: relative;
    padding-left: 35px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 22px;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.form-check input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    width: 20px;
    background-color: #eee;
    border: 1px solid #e3e4e5;
}

.form-check input:checked ~ .checkmark {
    background-color: purple;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.form-check input:checked ~ .checkmark:after {
    display: block;
}

.form-check .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 3px 3px 0;
    -webkit-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg
}
<div class="form-group">
    <div class="input checkbox">
        <div class="form-check">
            <label class="add-on form-check-label" for="basicContactForm-checkbox-1">
            <input name="tx_form_formframework[BasicContactForm][checkbox-1]" value="" type="hidden">
            <input required="required" class="add-on" id="basicContactForm-checkbox-1" name="tx_form_formframework[BasicContactForm][checkbox-1]" value="1" type="checkbox">
            <span class="checkmark"></span><!-- added for checkbox -->
            <span>Yes, I confirm!<span class="required">*</span></span>
            </label>
        </div>
    </div>
</div>