html - 无法让切换按钮向右浮动

标签 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

最佳答案

如果没有链接并且只有一些 CSS,很难提供帮助。您可以尝试以下操作吗:

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

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

.onoffswitch {
  float: right;
}

关于html - 无法让切换按钮向右浮动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35917691/

相关文章:

css - 如何在 Google Chrome 扩展中真正隔离样式表?

javascript - Chrome扩展消息传递: response not sent

javascript - Jquery 将文本字段的值插入到列表框中。?

html - 如何为搜索引擎不索引文本?

javascript - 如何增加垂直高度并在 Bootstrap 中的 div 滚动中的内容之间添加空间

html - 安迪克拉克的 "Universal Internet Explorer 6 CSS"vs 埃里克迈耶 "CSS Reset"

javascript - 从 Chrome 扩展程序访问 Google Maps API

javascript - 通过 Javascript 或控制台选择所有复选框

html - 如何为特定的表类设置响应代码?

html - 设置指向 <li> 的链接而不仅仅是文本