0

次のような順序付けられていないリストを使用するギャラリーがあります。

<ul>
    <li style="background: center no-repeat #bc874c url(images/image-01.jpg)"></li>
    <li style="background: center no-repeat #bc874c url(images/image-02.jpg)"></li>
    <li style="background: center no-repeat #bc874c url(images/image-03.jpg)"></li>
    <li style="background: center no-repeat #bc874c url(images/image-04.jpg)"></li>
</ul>

ご覧のとおり、要素の背景を使用して画像を表示しているので、ユーザーがli要素をクリックするとライトボックスが開きますが、それは可能ですか?

よろしくお願いします。

4

1 に答える 1

0

各 LI に onclick イベントを配置できますが、href リンクを各 LI 内に配置する方が簡単です。

<ul>
   <li onclick="alert('here');" style="background: center no-repeat #bc874c url(images/image-01.jpg)"></li>
   <li style="background: center no-repeat #bc874c url(images/image-02.jpg)"></li>
   <li style="background: center no-repeat #bc874c url(images/image-03.jpg)"></li>
   <li style="background: center no-repeat #bc874c url(images/image-04.jpg)"></li>
</ul>

おそらくjquery関数を作成し、画像のURLを変数として渡します..私に知らせてください.あなたのために何かを書くことができるかもしれません.

于 2012-12-25T05:27:35.823 に答える