-
AuthorPosts
-
June 29, 2021 at 5:03 am #1307845
Hello
I have a site that is going to have both black pages and white pages.1) I’d like to be able to assign the alternate/trans styling to the black, and use the main for white, including the logo. Other than using ids for pages and then styling elements is there a more straightforward way?
Black example:
http://keypropertymanagement.ca/about/
I’d like the logo and menu to be styled as if it was transparent – I can set it to transparent but it reverts back to white on scroll.
White example:
http://keypropertymanagement.ca/contact/
Fine as is except for the home page, which will be all white after the black intro anim.
2) For just the home page the menu shows only on scrolling but I’d like to have it underneath the 100% high animated section. I’m guessing I can put the animated banner into a widget but how do I get it to be above the header, please?
Thank you :)
July 2, 2021 at 2:29 pm #1308509Hey webWahine,
Thank you for your patience, perhaps try this script, you will note that it relies on the page ID to set the classes and add the logo, and is currently set for your about page page-id-33 so to use it for other pages you will need to adjust, but in my test it seems to work well.
Try adding this code to the end of your functions.php file in Appearance > Editor:function custom_script() { ?> <script> (function ($) { $(window).load(function() { $("#top.page-id-33 #header").addClass('av_header_transparency'); $('#top.page-id-33 .logo').append('<span class="subtext"><img src="https://keypropertymanagement.ca/wp-content/uploads/2021/06/KEY-Marketing-logo-white.svg" class="alternate" alt="KEY Marketing logo white" title=""></span>'); }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_script');
then add this code in the General Styling > Quick CSS field or in the WordPress > Customize > Additional CSS field:
#top.page-id-33 #header.av_header_transparency, #top.page-id-33 .av_header_transparency #header_main { background: #000 !important; }
After applying the css, please clear your browser cache and check.
Best regards,
MikeJuly 2, 2021 at 6:00 pm #1308534Hello, Mike
so my guess about resolving question 1) was applicable. It’s not a huge site so I can live with that, but assume I’ll have to repeat the functions PHP for each page that I want in black, correct, or can I set a variable and assign page-ids?
As for question 2), I’m playing around with using a fullwidth sub menu but can’t figure out how to add in the logo at left, and also include the fx border on hover/active. Would it be easier to place the animated gif above the header with some code, or try to finish off styling the fw submenu?
Thanks, again :)
July 3, 2021 at 5:53 pm #1308587Hi,
Instead of using page IDs you could add a class to all of your “black” styled pages and change the script to look for#top.black
instead of#top.page-id-33
To add this class to some of your pages you could use the WordPress Custom Fields option, the Custom Fields options on the Post & Page edit screens are hidden by default if they have not been used before. Using the Block Editor, click the three dots button at the top of the right sidebar and visit Options to enable it. (If you are using the Classic editor, check the screen options).
So in this case we will add the Name: bodyclass and the Value: black
to each one of these pages, then add this code to the end of your functions.php file in Appearance > Editor:function add_custom_fields_bodyclass( $classes ) { global $post; $bclass = get_post_meta( $post->ID, 'bodyclass', true ); if ( empty( $bclass ) ) { return $classes; } $classes[] = $bclass; return $classes; } add_filter( 'body_class', 'add_custom_fields_bodyclass' );
Please note that this only looks for the Name: bodyclass but it will add any value as a body class.
As for question #2 I’m not seeing the full-width sub-menu on your home page, which page are you testing on? Which animated gif are you referring to?Best regards,
MikeJuly 3, 2021 at 8:48 pm #1308596Ok, this is a much better option! We are getting close but it’s not working properly yet. I’ve set the class to the Services page as well.
1) Not always, the About page goes white on scroll. Eg, I click on the menu link and scroll and it goes white. If I hard refresh without leaving the page it remains black.
2) The newly class assigned Services page is showing an alpha of black before scrolling, then white on scrolling. If I hard refresh it goes black on scroll, but still with an alpha, so not opacity 1. I’m guessing it’s some other css that is effecting this?
As for the fw sub menu, I decided to keep working with this option because I couldn’t get the logo or the fx to display. I also really needed to move forward and can’t keep waiting days for a reply, so I’ve removed it for now.
I would like to know where to speed up the scroll speed on the 100% height home page, which has an id of #csaltanim, though. And older post referenced a location where it no longer exists. the home page currently has a static svg where the animated gif would go.
Another great feature would be to have #csaltanim fade to white or transparent – is that possible as well, please? Thanks, again :)
July 3, 2021 at 10:12 pm #1308604Sorry, I don’t mean to bump this abut another really crucial issue has arisen – the entire menu disappears on mobile! I’ve tried to play around and get it to show in @media only screen and (max-width: 989px) –
/* show main menu */ #top .av_header_transparency { display: visible !important; min-height: 200px!important; background: red !important; position: fixed; top: 0; }
No luck. It seems to load and then go all black…
July 4, 2021 at 3:48 pm #1308646Hi,
I don’t believe that this is a result of anything we have done in this thread, do you?
I tried taking a look at your mobile header, but I’m not sure what you are trying to achieve, typically on mobile the header is not sticky, are you trying to have it sticky but not shown until after scroll?
Your child theme stylesheet is quite confusing with a lot of empty rules and a lot of commented out rules, please try copying your whole stylesheet to your desktop and then remove everything, except the top few lines that tell WordPress the name of the child theme, then try adding back a few rules at a time testing and clearing your browser cache each time, try to not add anything that you know you don’t need, keeping it all clean.
This should help you find when the error occurred.Best regards,
MikeJuly 4, 2021 at 4:38 pm #1308651Hi, Mike
Mot sure… The mobile menu was there and now it’s gone. There are so many variables now, more so than ever, which doesn’t help matters.
Yes, I was hoping to have the mobile menu be sticky and visible on scroll for the home page only, and then just sticky for all other pages. Just getting it to appear again would be fine at this point.
I’m not sure why comments and empty rules contribute to any errors, if they are not applied? I’m not formally trained in css so the comments are really helpful, and I leave in the empty rules in case I need them again.
It would be a tall order to do what you suggest with my typically tight deadlines, so I guess I’ll just have to sort this out myself.
You’ve been helpful but I have other posts from days ago that have yet to be replied to, so I’m a bit frustrated about meeting my deadlines :)
July 6, 2021 at 11:24 am #1308916Hi,
Empty rules in themselves don’t cause errors, unless you are missing a bracket somewhere then it could cuase strange behaviors. In my experience checking the css like this often identifies the problem. You could try copying your whole stylesheet to your desktop and then remove everything, except the top few lines that tell WordPress the name of the child theme, then try adding back a few rules at a time testing and clearing your browser cache each time. I agree this may take a while with your 4000+ lines of code, but I believe it will identify the problem.Best regards,
MikeJuly 6, 2021 at 11:30 am #1308917Hi, Mike
I constantly watch my output for errors, so that’s not the issue. I’ve continued to work on this and for the about page on scroll the text and logo go to the non transparent styling, but I did manage to set the background to remain black. The key here is getting the transparent logo to remain on scroll… I’ll keep pulling code but if you have any insight it would be most appreciated :)
July 7, 2021 at 1:03 pm #1309098Hi,
It looks like you were able to sort this out, the header is now visible on scroll.Best regards,
MikeAugust 6, 2021 at 2:27 am #1314729Hello! Sorry for the delay. I’ve hacked things a bit but one item remains – when mobile, the logo reverts back to the non transparent version. Here’s all of my code (functions.php and css), to help others as well:
functions.php
//-------------------------------- // hack to use trans logo //-------------------------------- function custom_script() { ?> <script> (function ($) { $(window).load(function() { $("#top.page-id-932 #header").addClass('av_header_transparency'); $('#top.page-id-932 .logo').append('<span class="subtext"><img src="https://oneoakaustin.com/wp-content/uploads/2021/07/One-Oak-Bouldin-Creek-logo-transparent.svg" class="alternate" alt="Corporate logo" title=""></span>'); }); })(jQuery); </script> <?php } add_action('wp_footer', 'custom_script');
and my css:
/************************************************** logo swap hack in functions.php addition - home option page - 932 #header_main bg needs to be transparent **************************************************/ #top.page-id-932 #header.av_header_transparency, #top.page-id-932 .av_header_transparency #header_main { /* background: rgba(0, 0, 0, 0.5)!important; */ } /* force main bg on scrolling */ #top.page-id-932 .header_color .header_bg { /* background: #4a4747!important; dk mushroom */ } /* force pancake lines closed */ #top.page-id-932 .header_color .av-hamburger-inner, #top.page-id-932 .header_color .av-hamburger-inner::before, #top.page-id-932 .header_color .av-hamburger-inner::after { background-color: #c6b193 !important; /* taupe */ } /* force widget custom reg button */ #top.page-id-932 #header.header_color #header_main .widget a.buW2 { border: 1px solid #f2efee !important; /* off white */ color: #f2efee !important; /* off white */ background: #4a4747!important; /* dk mushroom */ margin-right: 50px !important; margin-top: 43px !important; width: 300px !important; } /* force pages to have a different bg after scrolling */ .page-id-932 #header_main { background: #4a4747!important; /* dk mushroom */ } /* custom main menu for alternate - before and after scrolling */ #top .page-id-932 .av-main-nav>li.current-menu-item>a>.avia-menu-text, #top .page-id-932 .av-main-nav>li.current-page-ancestor>a>.avia-menu-text { color: red!important; } #top .page-id-932 .av-main-nav li a:hover .avia-menu-text, #top .page-id-932 .av-main-nav li.current-menu-item > a > .avia-menu-text { color: blue !important; } #top .page-id-932 .av-main-nav>li.current-menu-item>a>.avia-menu-text, #top .page-id-932 .av-main-nav>li.current-page-ancestor>a>.avia-menu-text { color: blue !important; } /* smallest portrait phones *************************************************/ @media only screen and (max-width: 767px) { /* start max 767 */ #top.page-id-932 .responsive .logo img, .responsive.html_mobile_menu_tablet #top.page-id-932 .av_header_transparency.av_alternate_logo_active .logo a > img { height: 50px !important; width: auto!important; max-width: 100%; display: block; margin: 0px !important; /* max-height: 120px!important; */ } /* end max 767 */ }
August 7, 2021 at 6:23 pm #1315049Hi,
You could try this css:@media only screen and (max-width: 980px) { #top.page-id-932 #header.av_header_transparency .logo img.alternate { opacity: 1; display: block; } #top.page-id-932 #header.av_header_transparency.av_alternate_logo_active .logo a > img { opacity: 0; filter: alpha(opacity=0); } }
This looks like a different website than we were working on, since this thread is getting long let’s close this and open a new thread for new sites and topics.
Best regards,
Mike -
AuthorPosts
- The topic ‘Use both main and alternate/transparent meta and main menus on specific pages’ is closed to new replies.