CMS Development

hholman
Participant | Platinum Partner
Participant | Platinum Partner

Custom Classes

I've assigned the custom class custom-slider-main to my slider module.

When I try targeting .custom-slider-main in my custom css stylesheet, the styles aren't picked up by the page.

 

@media screen and (max-width: 480px) {
    .custom-main-slider {display: none;}
}

However, if I target the selector path, I see results:

@media screen and (max-width: 480px) {
   body > div.header-container-wrapper > div > div.row-fluid-wrapper.row-depth-1.row-number-3 > div > div {display: none;}
}

I can see the custom class name in the html code:

<div class="span12 widget-span widget-type-image_slider custom-main-slider" style="" data-widget-type="image_slider" data-x="0" data-w="12">
<div class="cell-wrapper layout-widget-wrapper">
<span id="hs_cos_wrapper_module_148216460768110517" class="hs_cos_wrapper hs_cos_wrapper_widget hs_cos_wrapper_type_image_slider" style="" data-hs-cos-general-type="widget" data-hs-cos-type="image_slider"><div id="hs_cos_flex_slider_module_148216460768110517" class="hs_cos_flex-slider flex-slider-main slider-mode-slider">

<div class="hs_cos_flex-viewport" …

What am I missing? 

0 Upvotes
6 Replies 6
Ty
HubSpot Employee
HubSpot Employee

Custom Classes

Hi @hholman,

 

Are you sure the styles aren't picking up? I hopped into your templates and see that you still have this style in the sheet:

@media screen and (min-width: 480px) and (max-width: 768px) {
    .custom-main-slider {display: none;}
}

And on the preview, I see this:

from 481px wide +

Screen Shot 2016-12-20 at 10.00.18 AM.png

 

And then once I hit 480px:

Screen Shot 2016-12-20 at 10.01.59 AM (2).png

Could this have just been a cacheing issue? Please let me know if this problem persists, I'll be happy to try and figure it out! From my end right now, everything seems to be working normally!

 

Thanks!

-- Ty

0 Upvotes
hholman
Participant | Platinum Partner
Participant | Platinum Partner

Custom Classes

I have caching disabled. 

 

I just went into my template and the stylesheet was using the selector path, not .custom-main-slider, hence I'm not sure how you were seeing the file contained .custom-main-slider. 

 

I've since changed it back to .custom-main-slider in the stead of  body > div.header-container-wrapper > div > div.row-fluid-wrapper.row-depth-1.row-number-3 > div > div and now display: none; is again not working.

 

I had this happen earlier with a custom class I assigned to the navigation. Apparently I'm not seeing something. For my mobile menu I've had to use body > div.header-container-wrapper > div > div.row-fluid-wrapper.row-depth-1.row-number-1 > div > div.span6.widget-span.widget-type-logo.zolo because targeting via existing classes isn't working. I can get it to respond by tweaking it in the web inspector, but not via my custom stylesheet. I feel like I'm missing something obvious.

 

Any help is thankfully welcomed.

0 Upvotes
hholman
Participant | Platinum Partner
Participant | Platinum Partner

Custom Classes

I went for the mini-hack and added !important

All seems good to go.

I'll live with it.

0 Upvotes
relabidin
HubSpot Alumni
HubSpot Alumni

Custom Classes

Hi @hholman,

 

Seems to me like a specificity issue, as in just calling the class .custom-main-slider isn't specific enough to override other styles that are affecting it. However, I am not a professional designer so I'm not 100% sure.

 

@ndwilliams3 and @stefen, do you guys have any thoughts on this?

 

Rami 

0 Upvotes
ndwilliams3
Key Advisor

Custom Classes

If this works

@media screen and (max-width: 480px) {
   body > div.header-container-wrapper > div > div.row-fluid-wrapper.row-depth-1.row-number-3 > div > div {display: none;}
}

but this does not

@media screen and (max-width: 480px) {
    .custom-main-slider {display: none;}
}

I would agree with @relabidin that there is a more specific style with display:block overriding it. Use inspect element in Chrome or Firefox. It's the easiest way to see which style declaration is taking priority.

 

0 Upvotes
stefen
Key Advisor | Partner
Key Advisor | Partner

Custom Classes

I agree with @relabidin that it's probably a specificity issue. Do you have a link you can share?

 

If you just want to hide it on mobile you could also use the class "hidden-phone".

Stefen Phelps, Community Champion, Kelp Web Developer
0 Upvotes