1

編集: CSS を DOM に正しく割り当てるコードの 2 つのブラケットで動作するフォークを取得しましたが、親 div の中央に配置されなくなりました。何か案は?

jQuery:

$("#container").hover(function () {
$("#innerFocusPrompt").position({
    my: "center center",
    at: "center center",
    of: "#container"
});
$("#innerFocusPrompt").css({
    "display": "inherit"
}).fadeIn(100);
});

CSS:

#container {
background-color: black;
color: #121212;
height:400px;
width:400px;
margin: 0 auto;
margin-top: 50px;
}
#innerFocusPrompt {
display: none;
background-color: red;
color: black;
height:100px;
width:100px;
}

http://jsfiddle.net/WASasquatch/7C2dc/1/

4

2 に答える 2

2

ハンドラーに割り当てcssていjQuery.position()ます。

次のようにDOMに割り当てることができます

$("#innerFocusPrompt").css({
    "display": "box"
});
于 2013-04-23T05:16:50.687 に答える
1

構文が正しくありません。要素の position() に .css を割り当てようとしています。

コードを次のように変更します。

$("#container").hover(function () {
   $("#innerFocusPrompt").position({
      my: "center center",
      at: "center center",
      of: "#container"
   });
   $("#innerFocusPrompt").css({
      "display": "box"
   });
});
于 2013-04-23T05:21:53.690 に答える