TYPO3表单 - 复选框的Bootstrap样式

问题描述 投票:0回答:2

是否有一个随时可用的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 twitter-bootstrap-3 typo3 typo3-8.x typo3-extensions
2个回答
2
投票

这样的事情会起作用

为你的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>

0
投票

只需将CSS添加到您的头部并按照github https://github.com/flatlogic/awesome-bootstrap-checkbox上的文档进行操作即可

© www.soinside.com 2019 - 2024. All rights reserved.