Posted: December 16, 2020 at 9:36 pm
I am very new to CSS and trying to customize the look of the button on the single event page using custom CSS. When I put the CSS in my child (parent is Divi) theme’s style.css file, it doesn’t have any impact on the event page’s button. I know it isn’t a problem with the child theme or file, because other customizations in the file work fine on the non EE4 pages. I am thinking I must not be following the proper syntax to reference the page and button. Below is what I have now. Would someone please help me figure out what I am doing wrong? Thanks in advance for the help. .single-espresso_events .ticket-selector-submit-btn { |
|
Hi Shelley, The syntax above is correct and it looks like it is applying on the page when I view it: https://monosnap.com/file/haAFMvxzlj1Rt4tIHLnIzD9TFNFg1a Have you already figured this out or do you see something different? |
|
Hi Tony, Since it worked for you, I tried a different approach. I put the CSS in the Additional CSS block under Appearance rather than in the child theme, and it works there. I guess there is some sort of conflict between the Divi child theme and the EE4 page. Thanks for verifying the syntax. Thanks, |
|
There shouldn’t be any conflict when using a child theme, it’s just another style sheet to load. I can check into that if you switch it back to using the child theme? |
|
Moved the CSS from the Additional CSS block to the child theme, and it is working now. Obviously, user error yesterday. Thanks again. |
|
You’re most welcome, it could also be some caching on the server meaning your browser still had the ‘original’ version and used that. In any case, I’m glad it’s now working 🙂 |
|
Another syntax question, please. I am now working on an event listing page. I am creating the page in Divi using the shortcode: [ESPRESSO_EVENTS]. I want to format the buttons the same way I did the single event button earlier in this message thread. I tried the following: .espresso_events .ticket-selector-submit-btn { It had no impact, so I assume I have a mistake in the initial reference “.espresso_events .ticket-selector-submit-btn.” Is my assumption correct? If yes, what should it be? I will no doubt need to make other similar adjustments on other pages created with shortcodes. Is there a reference article somewhere to tell me what the appropriate specifiers should be for each? |
|
It depends on the theme, EE events are output as posts by your theme so the classes are often determined by the theme itself. Can you post a link to the page in question so I can take a look?
Not currently, mainly because of the above. I find the best way to find the correct classes/IDs on the page is to use Chrome Dev Tools to view the elements and work back from there. If you can link me to the above page I’ll show you how I would work through to find the correct selectors from there. |
|
Thanks, Tony. A walkthrough of your process for determining the correct selectors would be incredibly helpful. The page I am trying to make the button modifications on is here: https://ljk.vandegriftphotography.com/ljk_dev/workshops-events-listing/. I want to make any buttons appearing on the page match the styling of other pages on our site. I feel pretty good about working with CSS, but I am really struggling with how to determine the correct selectors. I use the Inspect tool in Chrome to attempt to find the selectors, but I am obviously missing something. This is the first time I have tried to figure this out on plugin posts and pages. Thanks, |
|
That selector is correct, it’s working for me? I copied your styles into Chrome and it shows they apply: https://monosnap.com/file/AJMM1aqAQ2Ho5pugACmJLSUUX984jd What steps are you taking to test this? Based on this and your other thread I suspect there’s some form of Caching going on. |
|
Tony that is very odd. I have purged the caching and still do not get the correct result. What I am doing is this: -Using Chrome Inspect, try to figure out what the correct selector is (Would still really love to know your process for finding these) I just went in and cleared the cache then opened the page, and I still see the original, “out of the box” button styling. Can’t for the life of me figure out why you see it modified and I don’t. |
|
I don’t see it modified by default, I’m applying your styles in Chome Dev tools to confirm they work, which they do, but when I load the page I don’t see that styling. Ok, first, a quick guide on Chrome Dev Tools. Or a least how I use Chrome Dev Tools to find the selector I need. So you want to target the Ticket Selector button, right-click on it and do inspect. That will open Chrome Dev Tools on the inspect tab and select the element you are inspecting. Like this: https://monosnap.com/file/Djr4NEfKBH3jXtu7p1YjWPyoaV0yAN Do know the difference between ID’s and classes? ID’s use So knowing that we can look at the button input itself, if we use the ID it’s only going to target THAT specific button, but it has a class of So start with:
Now working up through the ‘parent’ elements allows us to get a little more specific on where those styles apply, so let’s use your example:
Work right to left and that says any element with class Looking at our inspector again: https://monosnap.com/file/jhgio9iYFfdoN9k5CGPUWN6dGlVdB1 Which means your selector is fine and will target that button, your specifically targeting that button within an element that has a class of Now, on your site your CHild theme’s CSS is currently using this selector:
Now you have a bit of a problem here as that’s specific targeting SINGLE espresso_events posts and an event list is NOT a single event post, its multiple. Notice in our inspector we do NOT have that https://ljk.vandegriftphotography.com/ljk_dev/events/infrared-a-to-z/ (When you’ve clicked through to the event) Use inspector again and you’ll see that class is on the above page, but you’ll also see is has an article element with class The above gets a little easier the more you do it, you start to notice classes that can be used on all the various sections you want to target and pick up how you can use the same class for multiple outputs, there isn’t really a shortcut to learning how to do that other than walking through it. May I ask why you switched to use |
|
I do know the basics of IDs and classes, but thanks for the refresher. When I added the shortcode to the page, I used this: [ESPRESSO_EVENTS css_class=”my-events-class”, show_title=false] So when I wrote the custom CSS, I wrote this: .my-events-class .view-details-btn { Earlier in the same child CSS I have a section to restyle the button on the single espresso event file which reads as follows: .single-espresso_events If I am understanding, you are saying I could just use .ticket-selector-submit-btn and it would apply to that button regardless of where it appears. I just tried that after clearing the cache and it doesn’t seem to be impacting any of the places this button appears. This is so frustrating. Just can’t figure out why this isn’t working. |
|
Don’t use quotes in the shortodes unless you have spaces in the attribute, my-events-class does not, also the comma is invalid. Each attribute is separated by a space, so that should be:
Although personally, I wouldn’t use the additional css_class there. — Where are you adding this additional code/changes? Your child theme style have not changed: https://ljk.vandegriftphotography.com/ljk_dev/wp-content/themes/LJKDiviChild/style.css?ver=4.7.7 |
|
I am making all changes in the child CSS. If you notice on the link you provided, (https://ljk.vandegriftphotography.com/ljk_dev/wp-content/themes/LJKDiviChild/style.css?ver=4.7.7 ) I commented out the single-espresso_events to try just specifying the ticket-selector-submit-btn. Didn’t make any difference. |
|
Found a workaround. I put the CSS in the Additional CSS section on the site rather than in a child theme. That worked. Who knows why the Child theme isn’t working. Oh well, the path of least resistance…. |
|
Odd, but I’m glad you found a working solution. |
|
The support post ‘Proper syntax for custom CSS’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.