別の投稿で、チェックボックスの代わりにカスタム画像を使用する方法を見ました。これは Web では便利で、スマートフォンでの指の使用には重要です。
私はフォームの繰り返し部分でそれを使用しようとしました:
<?php do { ?>
<div id="one"><?php echo $row_Articles['article_name']; ?>
</div>
<div>
<style>
input[type=checkbox] {
display:none;
}
input[type=checkbox] + label
{
background: url(../images/icons/unchecked.png) no-repeat;
height: 28px;
width: 28px;
display:inline-block;
padding: 0 0 0 0px;
}
input[type=checkbox] + label:hover
{
background: url(../images/icons/hover.png) no-repeat;
height: 28px;
width: 28px;
display:inline-block;
padding: 0 0 0 0px;
}
input[type=checkbox]:checked + label
{
background: url(../images/icons/checked.png) no-repeat;
height: 28px;
width: 28px;
display:inline-block;
padding: 0 0 0 0px;
}
</style>
<input name="auswahl[]" type="checkbox" id="auswahl[]" value="<?php echo $row_Articles['article_id']; ?>,<?php echo $row_Articles['article_name']; ?>"><label for="auswahl[]"></label>
</div>
<?php } while ($row_Articles = mysql_fetch_assoc($Articles)); ?>
未チェックのホバー画像はうまく機能しています。しかし、画像ボタンをクリックすると、常に最初のチェックボックスのみがチェックされた画像に変わります。同様に、最初の行のみをオフにすることができますが、任意の画像チェックボックスをクリックします。何時間も検索しましたが、結果はありませんでした。誰かが私の間違いを見ますか?
助けてくれてありがとう!