Hello, I have a problem that should be pretty simple to fix, hopefully. I am trying to implement a style field that allows the user to change the color of a button when the button is hovered over. Here is my component:
As the documentation states in the "Coding custom modules" articles from the css section, the .css file in the module has limited access to hubl templating, thus it is not possible to access the style variable from within it.
The solution to this restriction is to use the "{% require_css %}" function in the .html tab of the module in order to generate the styles needed.
So in your example, in the html tab, where you have the button tag, you should add the style tag like the following:
Hello and thank you for your answer! I have implemented the changes you suggested, but unfortunately the button refuses to change color. I do not have any styling for the button in the css file of the module, or anything else that would override the styling I have. Here is what I have currently:
Hello again @fordburgess , at this point the best thing would be if you could produce a public page where we can see the button. The css seems to be correct, maybe you could use developer tools, to inspect the element and see what happens on hover state...or maybe even check if some other styles are creating a conflict... also check for the "background" rule, as it tends to override the "background-color".
I wonder if this is due to Inline styles generally having higher specificity than external CSS styles. Have you tried using external CSS for all hover-related styles?
Thanks for the tag @Jaycee_Lewis, if this is inline, then you're correct, pseudo classes can't be used inline (regardless of their level in the cascading hierarchy).
@fordburgess when you say "allow the user to change the color", where are you coding this button?
Are you wanting the web user to change it in your theme settings so they can control the colors, or are you just saying you want the color to change when the user scrolls?
A little more context about what you're trying to achieve would be helpful.
If my reply answered your question please mark it as a solution to make it easier for others to find.
Hello Jennifer, thank you for your answer. To answer your question, this button is apart of a reusable module. My boss wants to have complete control over the styling (mainly the colors) of all the components in this module. Thus, I have created a style field for for everything, including the button hover color, so that when he is on the page editor creating his pages and he uses this module, he is able to change the color of the button, the border color, the hover color, etc.