Picture of Dan Jonsson
Hide block
by Dan Jonsson - Friday, 5 May 2017, 7:33 AM
 

How do I hide a block with CSS?

I want one block for mobile and one for full width!

 

D

Picture of Matt Leathes
Re: Hide block
by Matt Leathes - Friday, 5 May 2017, 8:56 AM
 

You'd be better off using adapt-hide; hiding via CSS alone would cause you progress bar/tracking problems as the course wouldn't know the user didn't have to complete that block.

The README for adapt-hide refers only to components but looking at the code I see no reason why it wouldn't also work on articles and blocks as well.

Picture of Dan Jonsson
Re: Hide block
by Dan Jonsson - Friday, 5 May 2017, 9:44 AM
 

Sorry it didn´t work! It hides the whole page!

 

D

Picture of Matt Leathes
Re: Hide block
by Matt Leathes - Friday, 5 May 2017, 10:34 AM
 

How did you configure it?

Picture of Dan Jonsson
Re: Hide block
by Dan Jonsson - Friday, 5 May 2017, 10:49 AM
 

I just added the 

"_hideOn": "small" to one of the components or blocks

and
"_hideOn": "medium large" to the other. Like this:

{
"_id": "b-45",
"_parentId": "a-11",
"_type": "block",
"_classes": "",
"_hideOn": "small",
"title": "",
"displayTitle": "",
"body": "",
"_trackingId": 13
},

 

D

 
Picture of Matt Leathes
Re: Hide block
by Matt Leathes - Friday, 5 May 2017, 11:34 AM
 

I have just pushed an update to it, maybe update and try again?

It's definitely working for me; using the out-of-the-box content I applied "_hideOn": "small" to b-05 and "_hideOn": "medium large" to b-10.

adapt hide on desktop

 

adapt hide on small screen

Picture of Dan Jonsson
Re: Hide block
by Dan Jonsson - Friday, 5 May 2017, 2:28 PM
 

The same result as before!

 

D

Picture of Matt Leathes
Re: Hide block
by Matt Leathes - Friday, 5 May 2017, 3:01 PM
 

Hmm sorry I don't know what to suggest, like I say it worked great for me...

Picture of Dan Jonsson
Re: Hide block
by Dan Jonsson - Friday, 5 May 2017, 9:47 AM
 

With some small adjustments this will work!

.component.narrative-component {
&.c-5182 {
display: none;
padding-top: 0px !important;
}
}
@media all and (max-width:@device-width-small) {
.component.narrative-component {
&.c-182 {
display: none;
padding-top: 0px !important;
}
&.c-5182 {
display: block;
}
}
}

 

D