Cakephp复选框css无法正常工作

时间:2014-05-18 23:56:38

标签: javascript html css cakephp

我想把它放在我的cakephp项目上

http://jsfiddle.net/UVFD7/

然而输出是这个 enter image description here

而不是jsfiddle中显示的那个,我该如何解决这个问题?

onoffswitch.css在webroot中

.onoffswitch {
    position: relative; width: 61px;
    -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}

.onoffswitch-checkbox {
    display: none;
}

.onoffswitch-label {
    display: block; overflow: hidden; cursor: pointer;
    border: 2px solid #999999; border-radius: 20px;
}

.onoffswitch-inner {
    width: 200%; margin-left: -100%;
    -moz-transition: margin 0.3s ease-in 0s; -webkit-transition: margin 0.3s ease-in 0s;
    -o-transition: margin 0.3s ease-in 0s; transition: margin 0.3s ease-in 0s;
}

.onoffswitch-inner:before, .onoffswitch-inner:after {
    float: left; width: 50%; height: 33px; padding: 0; line-height: 33px;
    font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
    -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}

.onoffswitch-inner:before {
    content: " ";
    padding-left: 10px;
    background-color: #4EDE4C; color: #FFFFFF;
}

.onoffswitch-inner:after {
    content: " ";
    padding-right: 10px;
    background-color: #EEEEEE; color: #999999;
    text-align: right;
}

.onoffswitch-switch {
    width: 31px; margin: 1px;
    background: #FFFFFF;
    border: 2px solid #999999; border-radius: 20px;
    position: absolute; top: 0; bottom: 0; right: 24px;
    -moz-transition: all 0.3s ease-in 0s; -webkit-transition: all 0.3s ease-in 0s;
    -o-transition: all 0.3s ease-in 0s; transition: all 0.3s ease-in 0s; 
}

.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
    margin-left: 0;
}

.onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
    right: 0px; 
}

感谢任何帮助,一整天都在打扰我,完整的代码在jsfiddle中

1 个答案:

答案 0 :(得分:0)

在这里你去..万一你看到它不#39;工作其他css可能会覆盖这个CSS。

同时检查导入的css中是否有复选框css

echo $this->Html->tag('div', (
        $this->Form->checkbox('onoffswitch', array('hiddenField' => false, 'id'=>'myonoffswitch', 'class'=>'onoffswitch-checkbox', "checked")).
        $this->Form->label('tick',(
                                     $this->Html->tag('div','',array('class'=>'onoffswitch-inner')).
                                     $this->Html->tag('div','',array('class'=>'onoffswitch-switch'))
                                ), 
                                array('class'=>"onoffswitch-label", 'for'=>"myonoffswitch"))        
), array('class'=>'onoffswitch'));