简体   繁体   中英

How to use lightbox options?

How I can to use lightbox 2 options? How to include in document? It does not work as specified on the site http://lokeshdhakar.com/projects/lightbox2/#options

<script>
    lightbox.option({
      'resizeDuration': 200,
      'wrapAround': true
    })
</script>


<a class="example-image-link" data-lightbox="example-set" href="pic.png">
  <img style="width: 100%" src="pic.png">
</a>

How do you set the lightbox options?

Make sure you are including both the lightbox.js AND lightbox.css stylesheet.

You will also need jQuery 1.7 or greater (as stated in step 4 of the Getting Started section of the Lightbox website ). You should include the jQuery script before the lightbox script.

This setup worked for me:

<!DOCTYPE html>
<html>

<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.7.1/css/lightbox.css" />
<script src="jquery-1.11.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.7.1/js/lightbox.min.js"></script>
</head>

<body>
<a class="example-image-link" data-lightbox="example-set" href="pic.png">
  <img style="width: 100%" src="pic.png">
</a>

<script>
lightbox.option({
  'resizeDuration': 200,
  'wrapAround': true
  })
</script>
</body>

</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM