<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Style fields for psuedo classes are not working in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/903112#M37377</link>
    <description>&lt;P&gt;Also, i just noticed that all the rules are inline, you could and should move them in the .my-button class.&lt;BR /&gt;&lt;BR /&gt;Also not sure it does but inline background-color could be the culprit here? Inline styles always have a greater hierarchy.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jan 2024 22:05:56 GMT</pubDate>
    <dc:creator>miljkovicmisa</dc:creator>
    <dc:date>2024-01-09T22:05:56Z</dc:date>
    <item>
      <title>Style fields for psuedo classes are not working</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/902529#M37357</link>
      <description>&lt;P&gt;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:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;button 
  class="my-button" 
  style="
  background-color: {{ module.style.button_color.color}}; 
  color: {{ module.style.button_text_color.color }}; 
  border: solid 2px {{ module.style.button_border_color.color }};
  position: absolute;
  bottom: 15%;
  padding: 15px;
  {{ module.style.button_alignment }}: 10%;
 "
 href="{{ module.button_url.href }}"&amp;gt;
 {{ module.button_text }}
&amp;lt;/button&amp;gt; &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and here is my css:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;.my-button {
  transition: 0.3s; 
 }
  
.my-button:hover {
  cursor: pointer;
  background-color: {{ module.style.button_hover_color.color }}; 
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's worth noting that the 'cursor: pointer' property does work, but nothing related to colors seem to work; it doesn't even work when I try to set the color statically. I have tried what was suggested on this similar post to no avail:&amp;nbsp;&lt;A href="https://community.hubspot.com/t5/CMS-Development/Using-Field-to-specifiy-CSS-attributes-for-Pseudo-classes/m-p/461665" target="_blank" rel="noopener"&gt;https://community.hubspot.com/t5/CMS-Development/Using-Field-to-specifiy-CSS-attributes-for-Pseudo-classes/m-p/461665&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated, thank you in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 22:31:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/902529#M37357</guid>
      <dc:creator>fordburgess</dc:creator>
      <dc:date>2024-01-08T22:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: Style fields for psuedo classes are not working</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/902972#M37367</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/475755"&gt;@fordburgess&lt;/a&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":waving_hand:"&gt;👋&lt;/span&gt; Thanks for your question! I'm not a CSS wizard, but I know a few — hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/91608"&gt;@alyssamwilie&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/166093"&gt;@miljkovicmisa&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/363300"&gt;@Jnix284&lt;/a&gt;, do&amp;nbsp;you have any tips for&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/475755"&gt;@fordburgess&lt;/a&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wonder if this is due to&amp;nbsp;&lt;SPAN&gt;Inline styles generally having higher specificity than external CSS styles. Have you tried using&amp;nbsp;external CSS for all hover-related styles?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jaycee&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 17:04:22 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/902972#M37367</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2024-01-09T17:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Style fields for psuedo classes are not working</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/902981#M37368</link>
      <description>&lt;P&gt;Thanks for the tag&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074"&gt;@Jaycee_Lewis&lt;/a&gt;, if this is inline, then you're correct, pseudo classes can't be used inline (regardless of their level in the cascading hierarchy).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/475755"&gt;@fordburgess&lt;/a&gt;&amp;nbsp;when you say "allow the user to change the color", where are you coding this button?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A little more context about what you're trying to achieve would be helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 17:15:19 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/902981#M37368</guid>
      <dc:creator>Jnix284</dc:creator>
      <dc:date>2024-01-09T17:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Style fields for psuedo classes are not working</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/902985#M37369</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/475755"&gt;@fordburgess&lt;/a&gt;&amp;nbsp;and welcome to the forum.&lt;BR /&gt;&lt;BR /&gt;As the documentation states in the &lt;A href="https://developers.hubspot.com/docs/cms/building-blocks/modules/files#css-module-css-" target="_blank" rel="noopener"&gt;"Coding custom modules"&lt;/A&gt; 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.&lt;BR /&gt;&lt;BR /&gt;The solution to this restriction is to use the "{% require_css %}" function in&amp;nbsp; the .html tab of the module in order to generate the styles needed.&lt;BR /&gt;&lt;BR /&gt;So in your example, in the html tab, where you have the button tag, you should add the style tag like the following:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;button 
  class="my-button" 
  style="
  background-color: {{ module.style.button_color.color}}; 
  color: {{ module.style.button_text_color.color }}; 
  border: solid 2px {{ module.style.button_border_color.color }};
  position: absolute;
  bottom: 15%;
  padding: 15px;
  {{ module.style.button_alignment }}: 10%;
 "
 href="{{ module.button_url.href }}"&amp;gt;
 {{ module.button_text }}
&amp;lt;/button&amp;gt;

{% require_css %}
  &amp;lt;style&amp;gt;
    .my-button {
      transition: 0.3s; 
    }
  
    .my-button:hover {
      cursor: pointer;
      background-color: {{ module.style.button_hover_color.color }}; 
    }
  &amp;lt;/style&amp;gt;
{% end_require_css %}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Also the {{&amp;nbsp;module.style.button_hover_color.color }} will produce a valid css color like this (#fdfdfd) so no need for further tinkering.&lt;BR /&gt;&lt;BR /&gt;If my answer was helpful please mark it as a solution.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 17:23:07 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/902985#M37369</guid>
      <dc:creator>miljkovicmisa</dc:creator>
      <dc:date>2024-01-09T17:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: Style fields for psuedo classes are not working</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/903049#M37373</link>
      <description>&lt;P&gt;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:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; &amp;lt;a
  class="my-button" 
    style="
    background-color: {{ module.style.button_color.color}}; 
    color: {{ module.style.button_text_color.color }}; 
    border: solid 2px {{ module.style.button_border_color.color }};
    position: absolute;
    bottom: 15%;
    padding: 15px;
    {{ module.style.button_alignment }}: 10%;
  "
  href="{{ module.button_url.href }}"&amp;gt;
  {{ module.button_text }}
 &amp;lt;/a&amp;gt;    
{% require_css %}
  &amp;lt;style&amp;gt;              
    .my-button {
      transition: 0.3s; 
    }

    .my-button:hover {
      cursor: pointer;
      background-color: {{ module.style.button_hover_color.color }}; 
     }
  &amp;lt;/style&amp;gt;
{% end_require_css %}&lt;/LI-CODE&gt;&lt;P&gt;Again, thank you for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 19:46:13 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/903049#M37373</guid>
      <dc:creator>fordburgess</dc:creator>
      <dc:date>2024-01-09T19:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Style fields for psuedo classes are not working</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/903052#M37374</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 19:48:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/903052#M37374</guid>
      <dc:creator>fordburgess</dc:creator>
      <dc:date>2024-01-09T19:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Style fields for psuedo classes are not working</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/903110#M37376</link>
      <description>&lt;P&gt;Hello again&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/475755"&gt;@fordburgess&lt;/a&gt;&amp;nbsp;, 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".&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 22:02:47 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/903110#M37376</guid>
      <dc:creator>miljkovicmisa</dc:creator>
      <dc:date>2024-01-09T22:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: Style fields for psuedo classes are not working</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/903112#M37377</link>
      <description>&lt;P&gt;Also, i just noticed that all the rules are inline, you could and should move them in the .my-button class.&lt;BR /&gt;&lt;BR /&gt;Also not sure it does but inline background-color could be the culprit here? Inline styles always have a greater hierarchy.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 22:05:56 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/903112#M37377</guid>
      <dc:creator>miljkovicmisa</dc:creator>
      <dc:date>2024-01-09T22:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Style fields for psuedo classes are not working</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/903296#M37379</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/475755"&gt;@fordburgess&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It looks like you need to add your CSS to the html.module between these tags -&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;{% require_css %}&lt;BR /&gt;&amp;lt;style&amp;gt;&lt;BR /&gt;...&lt;BR /&gt;&amp;lt;/style&amp;gt;&lt;BR /&gt;{% end_require_css %}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope this will helps you out. Please mark it as &lt;STRONG&gt;Solution Accepted &amp;amp; Upvote&lt;/STRONG&gt; to help other Community member.&lt;BR /&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 08:31:45 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Style-fields-for-psuedo-classes-are-not-working/m-p/903296#M37379</guid>
      <dc:creator>GRajput</dc:creator>
      <dc:date>2024-01-10T08:31:45Z</dc:date>
    </item>
  </channel>
</rss>

