li
要素の CSS に次を追加します。
margin-top: 72px; /*half of the height */
margin-bottom: -72px; /*half of the height (negative)*/
そう.slot li
なります:
.slot li{
width: 190px;
height: 144px;
background-color: blue;
float: left;
margin-top: 72px; /*half of the height */
margin-bottom: -72px; /*half of the height (negative)*/
}
アップデート:
背景色の問題を解決するには、クラスに次を追加background-color: yellow;
します。jSlots-wrapper
.jSlots-wrapper {
overflow: hidden; /* to hide the magic */
height: 296px; /* whatever the height of your list items are */
display: inline-block; /* to size width correctly, can use float too, or width*/
border: 1px solid #999;
position: absolute;
width:570px;
/*bottom: 130px;*/
margin-top: 2em;
left:50%;
margin-left: -285px;
padding: 0;
background-color: yellow;
}
アップデート:
の原理はbackground-color
画像にも当てはまります。クラスの を最後の要素に使用している画像にbackground-image
設定し、高さの半分 (負の値) だけ垂直方向にオフセットします。.jSlots-wrapper
li
li
更新されたフィドル: http://jsfiddle.net/3bVe9/6/概念実証用 (サイズ 256x256 の「ランダム画像」に GIS によって取得された画像を使用)
アップデート:
では、CSS 定義を次のように変更します.slot li
。
margin-top: 72px; /*half of the height */
margin-bottom: -72px; /*half of the height (negative)*/
に:
margin-top: -72px; /*half of the height (negative) */
margin-bottom: 72px; /*half of the height*/
そう.slot li
なります:
.slot li{
width: 190px;
height: 144px;
margin-top: -72px; /*half of the height (negative) */
margin-bottom: 72px; /*half of the height*/
background-color: blue;
float: left;
background-size: 190px 144px;
}
CSSの変更を.jSlots-wrapper
クラス定義に戻すと、問題は完全に修正されます(色と画像の両方について、別のフィドルがあります:http://jsfiddle.net/3bVe9/7/
これによりスロットが調整され、最初のスロットli
が上方にオフセットされ、2 番目のスロットli
が中央の開始点になります。再生ボタンをクリックするたびに完全に機能します。