0

我有以下脚本,它将一些按钮(现在是假按钮)添加到 div:

$("<div class='divButtons'>").appendTo( $(this).closest(".widget").find(".widget_header") );
// not real buttons, just text at the moment.  Trying to get the position right first.
$(".divButtons").text("(close), (min), (max), (help)").css({background:"red",float:"right"});

问题是,我不知道如何让 的右上角将divButtons自己定位到 parent 的右上角.widget_header。我试过添加top:some_number_here,但是用 jQueries 移动 div 时效果不佳ui-sortable

4

1 回答 1

1

您不必通过 javascript 指定样式属性,尝试在 .css 文件中添加类似这样的内容:

.widget_header {
    position: relative;
}

.your-top-right-corner-class {
    position: absolute;
    top: 0;
    right: 0;
}
于 2012-11-07T11:13:39.463 回答