无法将切换按钮向右浮动

时间:2016-03-10 13:18:58

标签: html css google-chrome-extension

我正在开发Chrome扩展程序,我从this site采取了一些可爱的切换开关,以添加到我的主页。

浮动似乎对切换没有影响,我想避免使用边距来定位它们。如果切换器在上面的第三组按钮下排成一行会很好。

有什么想法吗?

     <div class="row" id="row-6">
    <div class="debug">
      Debug Automation Chains
    </div>
    <div class="onoffswitch">
      <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="debug-switch">
      <label class="onoffswitch-label" for="debug-switch">
        <span class="onoffswitch-inner"></span>
        <span class="onoffswitch-switch"></span>
      </label>
    </div>
  </div>

  <div class="row" id="row-7">
    <div class="ui-dev-mode">
      UI Development Mode
    </div>
    <div class="onoffswitch">
      <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="devmode-switch">
      <label class="onoffswitch-label" for="devmode-switch">
        <span class="onoffswitch-inner"></span>
        <span class="onoffswitch-switch"></span>
      </label>
    </div>
  </div>`

`

.onoffswitch {
    position: relative;
    width: 90px;
    -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 #8F8F8F; border-radius: 10px;
}
.onoffswitch-inner {
    display: block; width: 200%; margin-left: -100%;
    transition: margin 0.3s ease-in 0s;
}
.onoffswitch-inner:before, .onoffswitch-inner:after {
    display: block; float: left; width: 50%; height: 17px; padding: 0; line-height: 17px;
    font-size: 10px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
    box-sizing: border-box;
}
.onoffswitch-inner:before {
    content: "ENABLED";
    padding-left: 10px;
    background-color: #00a3db; color: #FFFFFF;
}
.onoffswitch-inner:after {
    content: "DISABLED";
    padding-right: 10px;
    background-color: #EEEEEE; color: #999999;
    text-align: right;
}
.onoffswitch-switch {
    display: block; width: 9px; margin: 4px;
    background: #FFFFFF;
    position: absolute; top: 0; bottom: 0;
    right: 69px;
    border: 2px solid #8F8F8F; border-radius: 10px;
    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;
}

`enter image description here

1 个答案:

答案 0 :(得分:2)

如果没有链接,只有部分CSS,很难提供帮助。你可以尝试以下方法:

.row{
    display: block;
    float: left;
    width: 100%;
}

.debug, .ui-dev-mode {
    float: left;
}

.onoffswitch {
  float: right;
}