Gallery not working when container div is hidden (display:none)
See original GitHub issueI want the swiper gallery to show after clicking on a “Show the gallery” link. But it looks like Swiper is not working properly if initialized inside an hidden div.
Here is my page:
<div>
<a href=“javascript:;” onclick=“toggle_visibility('gallery');”><img src=“img.jpg” alt=“Click to open the gallery”></a>
</div>
<div id=“gallery” style:“display:none”>
<!— Swiper —>
<div id=“slide-event” class=“swiper-container swiper-container-event”>
<div class=“swiper-wrapper”>
…
</div>
<!— Add Arrows —>
<div id=“show-hide” class=“swiper-button-next”></div>
<div id=“show-hide” class=“swiper-button-prev”></div>
</div>
<!— End Swiper —>
</div>
<script src="js/swiper.jquery.js"></script>
Maybe there is a javascript trick? I read about a setTimeout function that could fix this issue. Any suggestion?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:20 (1 by maintainers)
Top Results From Across the Web
Css display none not working on div and its contents
Having a little trouble with css display:none. The problem is I want to hide a div that contains a repeater on large screens...
Read more >How To Find Out if an Element is Hidden - W3Schools
Note: When an element is hidden with display:none (like in the example above), the element will not take up any space. To find...
Read more >display - CSS: Cascading Style Sheets - MDN Web Docs
The display CSS property sets whether an element is treated as a block or inline element and the layout used for its children, ......
Read more >Hide or show elements in HTML using display property
The style display property is used to hide and show the content of HTML DOM by accessing the DOM element using JavaScript/jQuery.
Read more >Display property - Bootstrap
To hide elements simply use the .d-none class or one of the .d-{sm,md,lg,xl}-none classes for any responsive screen variation. To show an element...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It is far easier than this. Just add:
To the swiper initialization.
@wwwwwwoorks, thanks it works 👍