我正在用JavaScript制作一个简单的板球记分板。我基本上有一个div,每次点击它,它就在几个不同的背景图像之间循环。你能明白我的意思,。
示例1中的HTML是:
<div class = "click"></div>
所以这很好,但是我使用了一个全局变量来计数图像周期,所以当我尝试添加多个框时,就会发生这样的情况:
var x = 0;
$('.click').click(function() {
x++;
if (x == 4) {
x = 0;
}
switch (x) {
case 0:
我知道这个话题已经没完没了地讨论过了,但我尝试过许多解决方案,但没有一种解决方案奏效。在下面的片段中,我如何使图像垂直地居中于col/row div中?使用jQuery的解决方案是首选的(我更有可能破坏CSS)。我不知道图像的高度。
.row {
/* Just for demo */
border: 2px solid black;
}
/* My latest attempt at centering - this code can all be removed if desired*/
.book-image-container {
display: table;