简体   繁体   English

如何使两个div之间的差距固定?

[英]How to make gap between two div fixed?

In my page, their are two div;s which represent two rows . 在我的页面中,它们是两个div;它们代表两行。 i want to make the gap between those two div's fixed so that when i use drag and drop, the dropped item goes horizontally to the next item instead of going vertically. 我想固定两个div之间的距离,以便在使用拖放时,放置的项目会水平移动到下一个项目,而不是垂直移动。 please help thanks 请帮助谢谢

<div id="div1" style="background-color:#778899;height:30px;width:1030px;float:left;">
<b>Columns :</b>

<div id="div2" style="background-color:#778899;height:30px;width:1030px;float:left;">
<b>Rows :</b></div>

so in the coloumn div, im using droppable feature of jquery 所以在coloumn div中,我使用了jquery的droppable功能

$('#example-1-2 .sortable-list').sortable({ connectWith: '#example-1-1 .sortable-list' }); 

So the problem is that when I drop an item, the dropped item gets added like a column one below the other. 所以问题是当我放下一个项目时,被放下的项目像一个列一样被添加到另一个之下。 But what I want is that when I drop any item, it should get attached and like a row, one right to another. 但是我想要的是,当我放下任何项目时,它都应该像一条行一样被附着在一起,彼此之间是正确的。 The column div is below the row div. 列div在行div下方。 Therefore, I was asking if we could fix the size of both, and the dropped item will move then in a row like fashion. 因此,我问我们是否可以固定两者的大小,然后放置的物品将以类似的方式连续移动。

In your case their can be few problems 在你的情况下,他们可能是几个问题

1 the dropped item have float 1掉落的物品浮起

Solution remove that float 解决方案删除该浮动

2 the dropped item have Inline 2放置的项目具有内联

Solution Give that element Display:block so it can break out 解决方案 :为该元素提供Display:block,以便它可以爆发

the gaping of two divs is not affecting positioning of their child 两个div的间隔不影响其孩子的位置

Also post some of your code so we can see where the problem occurs. 还发布您的一些代码,以便我们可以看到问题出在哪里。 UPDATE use #div1 .sortable-item{display:inline; UPDATE使用#div1 .sortable-item {display:inline; width:20%;} 宽度:20%;}

the elements are showing block behavior just need to inline the elements 元素显示块行为,只需内联元素

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

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