简体   繁体   English

当幻灯片处于活动状态时,将 css 应用于祖父母 div

[英]apply css to grandparent div when slide is active

I have a carousel on my homepage .我的主页上有一个轮播。 When the third carousel appears, the carousel buttons div class="rotator-controls" move down due to the image taking space.当第三个轮播出现时,轮播按钮div class="rotator-controls"由于图像占用空间而向下移动。 My goal here is to keep this div the same height as the other 4. Which means that when the <span> (index 2) of the grandchild div <div class="rotator-pagination"> is active, I apply the correct css to the <div class="rotator-controls"> (eg bottom:60px).我的目标是保持这个 div 与其他 4 个相同的高度。这意味着当孙子 div <div class="rotator-pagination"><span> (索引 2)处于活动状态时,我应用正确的 css到<div class="rotator-controls"> (例如底部:60px)。 As the carousel is jQuery cycle 2, when the span is active it has the class cycle-pager-active .由于轮播是 jQuery 周期 2,当跨度处于活动状态时,它具有 class cycle-pager-active

I have tried using domcontentloaded.我尝试过使用 domcontentloaded。 ie IE

document.addEventListener("DOMContentLoaded", function() {
var span = document.querySelector("#homepage-rotator > div.banner.cycle-slide.cycle-slide-active > div > div.banner-content-area > div.rotator-controls > div.rotator-pagination").children[2];

if (jQuery(span).hasClass("cycle-pager-active")){
var grandPDiv = document.querySelector("div.rotator-controls");
grandPDiv.style.bottom = "-60px";
}
});

This does not work.这不起作用。 But if I do this in the console, and wait for the 3rd carousel to be acitve, using jQuery(span).hasClass("cycle-pager-active") returns true .但是,如果我在控制台中执行此操作,并等待第三个轮播激活,则使用jQuery(span).hasClass("cycle-pager-active")返回true How do i apply css (to its grandparent element) only when the span element is active?仅当 span 元素处于活动状态时,我如何应用 css (对其祖父元素)?

Try this尝试这个

.banner-content-area {
    min-height: 440px;
}

if not work then add min-height: 440px;important;如果不起作用,则添加 min-height: 440px;important;

This works perfectly:这完美地工作:

.banner-content-area {
    min-height: 440px;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当第一张幻灯片处于活动状态时,如何将“ first-slide-active”类应用于Slick轮播容器? - How to apply 'first-slide-active' class to Slick carousel container when first slide is active? 将此 div 幻灯片的左右箭头应用 CSS 样式? - Apply CSS styling to left and right arrows for this div slide? 当自定义元素没有值时,CSS 隐藏祖父 div 和所有子元素 - CSS hide grandparent div and all child elements when a custom element has no value 幻灯片加载时如何更改活动项目的CSS属性 - How to change CSS properties of an active item when slide loads 当 swiper 幻灯片处于活动状态时使用动画更改 css - Slider Swiper - Change css with animation when swiper slide is active - Slider Swiper 离开祖父母div时触发Mouseleave - Mouseleave triggering when leaving grandparent div 如何复制活动幻灯片的文本颜色并将其应用于另一个div - How do I copy an active slide's text color and apply it to another div CSS / JavaScript滑出DIV和滑入DIV - CSS/JavaScript slide DIV out and slide DIV in 使用 jquery 滑动时,一些 css 直到滑动后才适用 - When useing jquery slide some of the css doesnt apply until after the slide CSS-设置div宽度等于其“曾祖父母”的宽度 - CSS - Set div width equal to that of its “great-grandparent”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM