Javascript Cakephp复选框css不工作

Javascript Cakephp复选框css不工作,javascript,html,css,cakephp,Javascript,Html,Css,Cakephp,我正试图把这个放在我的cakephp项目上 然而,输出是这样的 我如何解决这个问题,而不是JSFIDLE中显示的问题 onoffswitch.css位于webroot中 .onoffswitch { position: relative; width: 61px; -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none; } .onoffswitch-checkbox { disp

我正试图把这个放在我的cakephp项目上

然而,输出是这样的

我如何解决这个问题,而不是JSFIDLE中显示的问题

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; 
}

感谢您的帮助,我已经绞尽脑汁一整天了,完整的代码都在JSFIDLE中。。如果您看到它不工作,其他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'));

这似乎是一个DOM问题。你能检查确保HTML被正确输出吗?所谓DOM问题,是指浏览器兼容性吗?我已经检查了html,它会输出复选框如果我删除cssby DOM问题,我的意思是检查并确保文档中的所有元素、标记和属性与JSFIDLE中的相同。尝试从布局中删除任何其他样式表。您可能有冲突的CSS。输出这种复选框的CakePHP代码是什么?