javascript - select2 对齐不起作用

标签 javascript jquery jquery-ui jquery-select2

select2-3.5.2 工作正常。但当我升级到 4.0.3 后,它突然出现在页面左侧。我正在使用 jquery-UI,希望这两个能够很好地协同工作。

float :右;对 select2-4.0.3 没有影响

    <div style="position:absolute; top:0px; left:0px; width:100%" class="ui-widget infobar-wrapper">
        <div name="ibar1" id="ibar1" class="ui-widget-header infobar">
            <select name="themes" id="themes" style="float:right;">  <!--margin-top:-3px;-->
              <option></option>
              <option value="black-tie">black-tie</option>
              <option value="trontastic">trontastic</option>
              <option value="ui-darkness">ui-darkness</option>
              <option value="ui-lightness">ui-lightness</option>
            </select>
        </div>
    </div>

当我在 JS 中这样做时:

$("#themes").select2({dropdownAutoWidth:true,placeholder:'Change theme'});

CSS:

.infobar {
    height:27px;
    font-weight:bold;
    overflow:hidden;
    border:0px;
}

最佳答案

似乎,但也似乎 float 应该移动到另一个项目。

CSS

.infobar {
  height: 27px;
  font-weight: bold;
  overflow: hidden;
  border: 0px;
}

.infobar .select2-container {
  float: right;
}

工作示例:https://jsfiddle.net/Twisty/Lq7q5xxj/

关于javascript - select2 对齐不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38679425/

相关文章:

javascript - 将模态框放置在 Vue.js 的子组件中

angular - 如何在 Angular 4 中导入 jquery-ui

javascript - 有什么方法可以将函数内的所有变量定义为 this 的属性?

javascript - 为 JavaScript 数组对象分配多个值

javascript - 使用纯 javascript 从 div 获取边框宽度

jQuery 选择前 n 个元素

javascript - XMPP - 示例第 3 章 "Professional XMPP Programming with JavaScript and jQuery"不起作用

javascript - Knockout js 数据绑定(bind)属性未重定向正确的页面

javascript - 从 Click 回调函数中访问 JQuery UI Widget

javascript - jQuery UI 对话框的视频问题