Carousel set height to 0 if the image is cached.
See original GitHub issueDescription
Carousel set height to 0 if the image is cached.
Repro Steps
- Create a html in local server
image.jpg
should be a local image, or a server support cache.
<!DOCTYPE html>
<html>
<head>
<!--Import Google Icon Font-->
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/css/materialize.min.css">
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div class="carousel carousel-slider">
<a class="carousel-item"><img src="image.jpg"></a>
<a class="carousel-item"><img src="image.jpg"></a>
<a class="carousel-item"><img src="image.jpg"></a>
<a class="carousel-item"><img src="image.jpg"></a>
</div>
<a class="waves-effect waves-light btn">Force Resize</a>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/js/materialize.min.js"></script>
<script>
$('.carousel.carousel-slider').carousel({fullWidth: true});
$('.btn').click(function () {
$('.carousel').height(400);
});
</script>
</body>
</html>
- Refresh the page
load
event will not be trigger if a image cached, but I apply the fix, it also set the height to zero, refer to jQuery doc, it is bad to get a height of a hidden
element.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Twitter Bootstrap carousel different height images cause ...
It looks like bootstrap less/CSS forces an automatic height to avoid stretching the image when the width has to change to be responsive....
Read more >How To Resize The Carousel From The New Templates
If the images are pixelated... then use images that are appropriate for the carousel's width/height. For example, if your image has a height...
Read more >Simple, Functional, Flexible: Building a Better Breed of Slider
The .fh-carousel also has the same positioning, for its child elements (along with a line-height of 0 to prevent extra padding at the...
Read more >Topic Tag: image height
Topic Tag: image height · [immonex Kickstart] Changing the height of the slider on the property detail page. Started by: andrejsantic · 2...
Read more >Preventing Content Reflow From Lazy-Loaded Images
When a user scrolls and images are lazy-loaded, those img elements go from a height of 0 pixels to whatever they need to...
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 FreeTop 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
Top GitHub Comments
I’ve managed to make this responsive and get around the height issue by adding
height: 450px !important
to.carousel-slider
and then have used the following jQuery to automatically resize it when the screen width changes.carouselHeight()
can also be called just after initialisation to fix the initial height issue.First we have a problem in height that does not adjust and is caught. Then we can not put the carousel in the desired width. When resizing the canvas in portrait or landscape on mobile devices, the carousel completely exits the screen configuration. Finally, it is not responsive. Not a desirable plugin. Automatic translator of portuguese