Draggable object “glued” to border

2019-08-08 18:03发布

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条回答
倾城 Initia
2楼-- · 2019-08-08 18:50

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

查看更多
登录 后发表回答