TYPO3表单 - 复选框的Bootstrap样式

时间:2018-05-16 16:36:46

标签: css twitter-bootstrap-3 typo3 typo3-8.x typo3-extensions

是否有可以使用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/

实现这一目标的最佳方式是什么?

2 个答案:

答案 0 :(得分:2)

这样的事情会起作用

为您的html添加了一个范围 - 请参阅下面的注释 其余的只是css - 我希望这可以帮助你

如果你不能添加任何html并且它必须是直接css,那么这个fiddle将起作用(我能做到最好)。扩展这个CSS应该做的伎俩

&#13;
&#13;
.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
}
&#13;
<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>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

只需将CSS添加到您的头脑中,然后按照github上的文档https://github.com/flatlogic/awesome-bootstrap-checkbox

进行操作