Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
JQuery でScrollToメソッドを使用しています。フォーカスされた要素を水平方向に集中させることはできますか?
どんな助けでも
はい、ウィンドウの高さには $(window).height() を使用し、画面の中央位置の計算には $(document).scrollTop() (ドキュメントの開始位置と現在のスクロール高さの間のスペース) を使用できます。
var middleHeight = $(document).scrollTop() + $(window).height() / 2.0;