-
AuthorPosts
-
March 14, 2018 at 2:08 pm #926610
Hi,
I’m trying to style pages which have a sidebar differently from those without sidebar.
I couldn’t find a top level class to differenciate both kinds of pages, does Enfold do that ?
If not, could you help me find a way to add a body class for pages with sidebar, I’m thinking for example of a “has_sidebar” body class for all pages with sidebar.
ThanksMarch 15, 2018 at 1:18 pm #927284Hey mike235,
For pages the sidebar class is under the ID #main and class .container_wrap
So for example:#top #wrap_all #main .sidebar_right
add your target afterwards
Best regards,
MikeMarch 15, 2018 at 1:31 pm #927298Hi Mike,
Here’s a real example, how would you style the H1 (class “main-title”) on a page without a sidebar, and on a page with a sidebar ?
I haven’t found a way to do that, because AFAIK Enfold doesn’t add a higher level class (in body for example) which allows us to differentiate pages with and without sidebars.
ThanksMarch 15, 2018 at 1:49 pm #927317Hi,
Assuming that your default style for h1 is going to be your style for pages without a sidebar, then we will change the style when the
left sidebar is is place:#top #wrap_all #main .sidebar_left h1 {color: red !important;}
for either sidebar:
#top #wrap_all #main .sidebar_left h1,#top #wrap_all #main .sidebar_right h1 {color: red !important;}
On my test page the h1 was a special heading, so I prefer:
#top #wrap_all #main .sidebar_left h1.av-special-heading-tag {color: red !important;}
Best regards,
MikeMarch 15, 2018 at 2:10 pm #927335Thanks for the quick reply. If we look at the source code :
<div class='stretch_full container_wrap alternate_color light_bg_color title_container'> <div class='container'> <h1 class='main-title entry-title'> <a href='' rel='bookmark' title='Lien permanent : Évaluer' itemprop="headline" >Évaluer</a> </h1> etc... <div class='container_wrap container_wrap_first main_color sidebar_right'>
I’m trying to style the H1 with class main-title, the main title of the page, which is located before the sidebar_right class. So your code would only work for any H1 that is inside the container_wrap with the sidebar class.
I guess I’ll just have to move the title code after the container wrap, but I’d have preferred not touch the templates..
- This reply was modified 6 years, 8 months ago by mike235.
March 15, 2018 at 9:45 pm #927742Hi,
it would require unfortunately for that move that you said, as there is no easier way we are afraid.
Best regards,
BasilisApril 3, 2018 at 4:55 pm #936650Hi,
Here’s how I solved the problem, in case anybody else is interested.
This adds a “entry_with_sidebar / entry_without_sidebar” class to the body tag :
function mwm_add_body_classes( $classes ) { $avia_config['size'] = avia_layout_class( 'main' , false) == 'fullsize' ? 'entry_without_sidebar' : 'entry_with_sidebar'; $classes[] = $avia_config['size']; return $classes; } add_filter( 'body_class', 'mwm_add_body_classes' );
April 3, 2018 at 11:51 pm #936863Hi,
Thank you for updating us and providing the class, we appreciate it a lot!
Best regards,
Basilis -
AuthorPosts
- The topic ‘Body class for pages with sidebar’ is closed to new replies.