amp-carousel: bug #6243 still unresolved - "dirty" height of slides-container
height: 100%!important; in /extensions/amp-caruosel/0.1/amp-carousel.css:1 makes .i-amphtml-slides-container height "dirty" - if there are more than 1 slides in caruosel, an unwanted bottom gap/margin is formed.
Adding .i-amphtml-slides-container {height: auto !important;} fixes the issue (pretty much all modern browsers and OS's) and leaves slide scroll intact, but makes the page not valid.
Possible solution: Please omit css parameter 'height: 100%' or at least !important rule and allow valid overriding, thanks.
My use case:
amp-carousel controls loop width="1920px" height="1080px" layout="responsive" type="slides"
div class='slide' amp-img src="/image.jpg" width="1920px" height="1080px" layout="responsive"></amp-img div class='title'>Title</div* /div
div class='slide' amp-youtube data-videoid="abc" width="1920px" height="1080px" layout="responsive"></amp-youtube div class='title'>Title</div /div
/amp-carousel
I came across a similar issue to this when trying to make <amp-lightbox-gallery>, mostly I took issue with the height: 100% !important that's applied to .i-amphtml-slide-item. This actually overrides the default height on the item inside the carousel slide.
I think we want to keep the height 100% on .i-amphtml-slides-container, since that guarantees that the slide container will have full height of the screen, but we want to change or allow overrides to .i-amphtml-slide-item, as not to modify the default height of the item inside the carousel. Will that work for your use case? What I'm seeing so far in what you've put up there is a <amp-youtube> component inside <amp-carousel> with layout="responsive", which is one of the use cases I've tested.
Hi Cathy,
Thank you for your quick response. I tried your solution, but unfortunatelly it does not work for me. Then I discovered .i-amphtml-slide-item already has height: 100% !important specified in /extensions/amp-carousel/0.1/amp-carousel.css
I assume 100% height for .i-amphtml-slides-container is there for the case where slide image is smaller than container or there is no images/videos/etc at all, but then the height for slide-item should resolve all issues anyway... maybe I am wrong. :)
My case is situated at https://expo.online and due to design choices, this issue is quite critical.
@MarkkiPiho which carousel on your website contains the <amp-youtube> or repro? Sorry, I could not find it.
What I meant was that instead of adding .i-amphtml-slides-container {height: auto !important;} to your CSS, add .i-amphtml-slides-item {height: auto !important;} instead. This will have the same invalid amp page problem as your original solution, but I think (of course pending investigation), we may be able to relax this constraint or reset the default height on .i-amphtml-slides-item to auto. I can make that code change, and then you can use .i-amphtml-slides-item {height: auto !important;} as a solution (or even omit it altogether) as a solution without invalidating your page. Sorry if that wasn't clear in my first comment. >.<
For example https://expo.online/en/vehicles/cars/mercedes-benz/#vision-mercedes-maybach-6 (first slide) or
https://expo.online/en/work/forestry-woodworking/forest-harvesting/#fr28-compact-forwarder (last slide)
Yes I did and the gap did appear. I can change it again for some time so you can check, if needed.
Hmm. I can indeed verify that this is an issue on your website, but I'm having quite a bit of trouble finding an isolated repro. I've coped your carousel and full page CSS here, but there's no gap: https://codepen.io/cathyxz/full/aqQZgR/
On your page specifically, <amp-youtube> is correctly sized, and <amp-carousel> is correctly sized. Oddly, the div for i-amphtml-slides-container (height: 100%) isn't sizing itself correctly to the height of it's parent (<amp-carousel>), whose height is correct...
Let me know if you can find an isolated repro of your bug. I'll circle back here after I finish digging into the history of <amp-carousel>'s height: 100%.
Thanks. There is a gap at https://codepen.io/cathyxz/full/aqQZgR/ using Chrome or Firefox on Windows 10.
Also with Edge.
GWD ran into the same issue.
@MarkkiPiho I think a temporary workaround is to add a class / id to your <amp-carousel> and use the css descendant selector to apply height: auto !important to the .i-amphtml-slides-container class. We can try setting .i-amphtml-slides-container to height: auto, but will have to rollback if this breaks anyone else.
Thank you. I tried that - carousel got class .carousel and css .carousel div {height: auto !important;}. It did work, gap went away, but messed up prev & next button height, that are on the same css level as .i-amphtml-slides-container. And because of !important rule, it still did not validate.
Hi Cathy,
How are you? Do you have any news about this issue?
Best regards,
Markki
Hi @MarkkiPiho !
Thanks for the ping. Unfortunately, we don't have the bandwidth to address this issue at this point in time. I'm hoping to slate it for next quarter, as part of a planned refactor on <amp-carousel>.
Hi Cathy,
Thank You for your quick answer. That's a shame. But I keep my fingers crossed for the next quarter, because the issue has been around since 2016.
By any chance, would it be possible to remove at least !important attribute from .i-amphtml-slides-container sooner, so it can me overridden in valid way, if needed. For me it seems almost impossible to use it in a bad way, because amp-carousel overflow is hidden.
Thanks again and best of luck!
Markki
Assigning back to @ericlindley-g and @aghassemi for prioritization. @kevinkassimo ran into this issue today too on MacOSX. It seems like a good time to revisit?
/cc @nainar for visibility. Does seem like a good time to look into this—though I'm not quite sure I understand the issue here . If there's a page demonstrating the issue it would be great to see, but if there's not we can wait until @nainar is back to take a look.
So there seems to be a way to fix it on Chrome/Safari, by adding
.i-amphtml-slides-container::-webkit-scrollbar {
height: 0px !important;
}
but not yet on other browsers.
Thanks—I can repro. In person @kevinkassimo noted that it was probably related to the scrollbar hiding we're doing. When the carousel is on a white background the effect is subtle, but I could imagine it being a bit worse in other cases.
Given the complexity of the component it probably makes sense to wait until @nainar or @aghassemi can take a look next week since they're more focused on the component these days.
Do we know how long the specific issue captured in @kevinkassimo 's screenshot has been in prod?
I was having this problem. The above code suggested by @kevinkassimo minus the "!important" works for me on Chrome .i-amphtml-slides-container::-webkit-scrollbar { height: 0px; }
Worth noting here that I can't repro this issue on ABE on a laptop screen - needs a large enough screen for this to become an issue. Have previous posters been having this issue on smaller screens too?
