繁体   English   中英

如何设计rubaxa可排序元素的初始位置

[英]how to styling initial place of rubaxa sortable element

我使用rubaxa的sortable库创建了sortable元素。 我想在元素完全移动之前自定义其初始位置的样式,例如此可排序

它的背景是蔚蓝的虚线框。

的HTML

<ul id="sortableContent">
    <li class="input-group fileItem">
        <div class="input-group">
            <input class="form-control inputItem" name="page_content[]" type="text"><span class="rm-content input-group-addon"><i class="fa fa-times"></i></span><span class="mv-content input-group-addon"><i class="fa fa-arrows"></i></span>
        </div>
    </li>
    <li class="input-group fileItem">
        <div class="input-group">
            <input class="form-control inputItem" name="page_content[]" type="text"><span class="rm-content input-group-addon"><i class="fa fa-times"></i></span><span class="mv-content input-group-addon"><i class="fa fa-arrows"></i></span>
        </div>
    </li>
</ul>

的CSS

.input-group .form-control {
  position: relative;
  z-index: 2;
  float: left;
  width: 100%;
  margin-bottom: 0;
}
.input-group .form-control:not(:first-child):not(:last-child),
#sortableContent .input-group-addon:not(:first-child):not(:last-child) {
  border-radius: 0;
}
.input-group .form-control:first-child,
.input-group-addon:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
#sortableContent .input-group-addon {
  width: 1%;
}
#sortableContent .input-group-addon {
    padding: 5px 7px;
    font-size: 12px;
    line-height: 1;
    text-align: center;
    background-color: #fff;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    border-right: 1px solid #ddd;
    border-left: none;
}

#sortableContent li, #sortableContent div, #sortableContent input {
    width: 100%;
}


#sortableContent { margin-bottom: 15px; padding-left: 0;}
#sortableContent li.fileItem { list-style: none; margin: 5px 0; }
#sortableContent li:last-child, #sortableContent li.fileItem .input-group { margin-bottom: 0; }
#sortableContent li.fileItem .rm-content { border-left-style: none; cursor: pointer; color: red; }
#sortableContent li.fileItem .rm-content:hover { background: #ccc; }
#sortableContent li.fileItem .mv-content { z-index: 1000; cursor: move; cursor: -webkit-grabbing; }

这是jsfiddle

您正在寻找的是ghostClass选项:

var sortable = new Sortable(el, {
    ...
    ghostClass = 'my-custom-class',
    ...
})

只需使“ my-custom-class”具有您想要的css(和名称),这就是中阻力的样子。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM