Draggable object “glued” to border

雨燕双飞 提交于 2019-12-11 10:44:07

问题


I've created a user control that includes a label inside a draggable div, like this:

<style type="text/css">
.text_label
{

    margin-top:8px;
    font-size:18px;
    color:#545454;
    -moz-border-radius: 2px;
    -webkit-border-radius: 2px;
    -border-radius: 2px;
}

.clear
{
    clear:both;
    height:20px;
}

.drag
{
    display:block;
}

</style>

<div class="drag">
<asp:Label ID="lbl1" class="text_label" runat="server" Text="Click Me"/>
</div>
<div class="clear"></div>

For draggable I'm using the following option in the ready() function:

$('.drag').draggable("option", "containment", 'parent');

On my test web page I'm adding two of the user controls inside a panel. My goal is to make them draggable inside that panel.

<style type="text/css">
    .panel
    {
        border-style:solid;
        border-width:medium;
        width:100%;

    }

</style>
<asp:Panel runat="server" ID="p1" CssClass="panel">
    <cc:UserControl1 runat="server" ID="Text1"  />
    <cc:UserControl2 runat="server" ID="Text2" />
</asp:Panel>

When I run the page (in Chrome), both controls are aligned to the right border of the panel are draggable only on the Y axis.

Any idea why it happens and what is missing?

Thank You.


回答1:


May be it is sticking down because of the class clear which has clear:both



来源:https://stackoverflow.com/questions/12871498/draggable-object-glued-to-border

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!