Support » Fixing WordPress » How come I have to use different codes to change the color of the SVGs?

  • Resolved ildomandatore

    (@ildomandatore)


    How do I change the color of the icons? With some I was able to make the desired changes.

    I would like to;
    – Changing the color of the icons.
    – Changing the color of icons on mouseover.

    https://postimg.cc/8ffYxWjx

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 17 total)
  • Beda

    (@bedas)

    Those icons are not something provided or part of WordPress. Maybe they are from a theme, or plugin, or custom code, but “Fixing WordPress” is not the right place to discuss issues relate to those icons, as they are clearly not part of WordPress.

    To Change colors of SVG you can either use CSS or alter the SVG color="" attribute.

    For changes on mouse hover, you will need to apply CSS on the :hover status of the element (icon)

    Have a look at this “tutorial”, I am sure it will help you greatly:
    https://css-tricks.com/change-color-of-svg-on-hover/

    Yogesh Yadav

    (@yogeshyadav20)

    Hi @ildomandatore
    You can change your svg icon color and hover color like this

    .ql-snow svg{filter:invert(48%) sepia(79%) saturate(2476%) hue-rotate(86deg) brightness(118%) contrast(119%);}
    .ql-snow svg:hover{filter:invert(48%) sepia(79%) saturate(2476%) hue-rotate(86deg) brightness(118%) contrast(119%);}
    Thread Starter ildomandatore

    (@ildomandatore)

    Out of inattention I forgot to put! Important in the icon color choices on Chrome’s Dev Tolls.

    I saved the link @bedas gave me, in case I need it.

    They gave me codes to center an icon, now I would like another icon to do the same. How do I know exactly which classes and ids I should use?

    Thread Starter ildomandatore

    (@ildomandatore)

    This is the sample code.

    #wpdcom  i.fa-image{
        display: flex;
        justify-content: center;
        align-items: center;
    }
    Beda

    (@bedas)

    How do I know exactly which classes and ids I should use?

    Generally you will know if you build the HTML, and if not, you can use the Browser Consoles, to analyse the resource, and get the classes or IDs from there, to use then in the CSS.

    You can read more about this here https://developer.chrome.com/docs/devtools/overview/#elements

    The sample code you share simply addresses a FontAwesome Icon residing inside a #wpdcom parent element (could be a div or anything else). So after locating the classes and/or parent IDs of your elements using the console, you can adapt your css to address those.

    Thread Starter ildomandatore

    (@ildomandatore)

    The page you linked to me is terrifying; Full of links and that does not explain anything. Never seen a worse page than this. However I had already read something, obviously understanding nothing. Maybe you should link the exact page. 🙂

    I have read several guides on the Chrome Dev Tool several times, but why don’t they explain how to recognize the path of the elements and how to copy them quickly? If I don’t find them in the CSS, it becomes a titanic undertaking; it takes more than an hour if I’m lucky, or I can’t even find what I’m looking for.

    I am not sure what you mean by exact page.
    That is the exact page that explains the usage of Chrome Console Elements section.

    In short, open the Browser Console, the by default open panel is the Elements section.
    There, you find all HTML that is on you page. Now, you can use the “cursor/arrow” that you find top left to locate things on your website, that will then highlight those items in the Elements Section (the HTML)
    Reading that, you will be able to see things like class or id and those are the values you are looking for.

    To the right of the elements section, you have the CSS browser, which by default will show all the CSS applied to the “active” HTML item, so if you click on a certain HTML line in the Elements tab, the CSSS for that already display on the right hand.
    And, next to the CSS rule, you even will find the “link” to the file that stores that CSS.

    I tried to take a few screenshots.

    1. Locate Elements and use the “arrow thingy” to locate items in the page:
    https://drive.google.com/file/d/1u5m_F0Pr3FEwBrLEP4sfOCuklfPjILJn/view?usp=sharing
    2. Click on any element on the page using that arrow thingy, to highlight that specific HTML in the Elements section:
    https://drive.google.com/file/d/1_2_4rmkpuB9u4-gbvUksrZzOY4hSpqB7/view?usp=sharing
    3. Now see the CSS in the right hand sidebar and also the links to the related files:
    https://drive.google.com/file/d/1GpafZb1PCE1W6tHJpiq5HETqwi0Hn0Or/view?usp=sharing

    I hope this helps. The console is a bit confusing at the begin, the best is to mess around with it, see what it does when clicking where, reading its code that it shows in the specific Elements Window, and try to edit the CSS on the right hand, to see what effects it has.. it takes a while to get familiar with it even after years, there is always something new to learn in those consoles, specially also because not every browser console is the same as the other

    Thread Starter ildomandatore

    (@ildomandatore)

    I have read the Chrome guides that you linked to me. This time I understood a lot of things.

    I thought my knowledge was similar and that nothing would change to re-read. I was convinced that I would dovutoaccumulato experience.

    There are 2 things left that I don’t understand;

    https://postimg.cc/gallery/drnNM0H

    Beda

    (@bedas)

    What you show in the screenshots basically is what the current active/hovered item uses as classes, so in one case, it is the body tag with class page-template-default and class page and class page-id-1115 and so forth.

    Some of those classes in this case are added by WordPress (for example page-id-1115 is generated by static page-id and the current page ID…)

    In the other case it is just another tag (div), instead of the body tag…

    Is that helping?
    I am not sure exactly what you aren’t clear about of the things in the screenshot, so if it did not help, please feel free to elaborate… we can then see to clarify things further 🙂

    Thread Starter ildomandatore

    (@ildomandatore)

    Sorry I did not understand. Could you explain in a simpler way?

    Beda

    (@bedas)

    The screenshot show html elements with their css classes

    Html elements are things like div, body, h1, p
    They have classes and those are usually denoted by a dot (.) before the class name

    So “div.something” means a html div element with class “something”

    Makes sense?

    Thread Starter ildomandatore

    (@ildomandatore)

    But how do I interpret those two things? I see there are ids and classes, but I don’t understand how to read them.

    Beda

    (@bedas)

    As said, those are classes and IDs

    Later you use those in css like for example so:

    .myclass {
    color:red;
    }
    #myID {
    color:blue;
    }

    As you see dots delimit classes and # hashtags delimit IDs
    Those are also visible in the html as actual “class” and “id” attributes

    Thread Starter ildomandatore

    (@ildomandatore)

    I am convinced that we are not understanding each other. I am asking something else entirely;

    Under the DOM, there is a path. I would like to know more.
    https://postimg.cc/mt6sTmqG

    There are inherited CSS; How do I put the classes and ids on these in the theme?
    https://postimg.cc/Y4CYQqRF

    I add a third thing. I realized that I didn’t get the answer I wanted;
    I find myself adding pseudo-classes as hover, but it doesn’t always work. In fact, I find that they recommend codes without :hover. I am confused.

    Beda

    (@bedas)

    What you show in the screenshot is once html with some html elements and classes and once some css…

    I don’t understand your question in regards of that if there is any

    To add css to your theme you add it (the css) either to the customizer in the dashboard > appearance menu or to a child theme style css file.

    To add styles to let’s say a hover status (when you hover a link) you would add something like .myclass:hover {color:red;} to for example control the hover status of a link (html “a” element) with class “myclass”

    Here are a few resources
    Css in general
    https://www.google.ch/amp/s/themeisle.com/blog/css-in-wordpress/
    Child theme style file
    https://developer.wordpress.org/themes/basics/main-stylesheet-style-css/
    More about css
    https://www.elegantthemes.com/blog/wordpress/basic-css-that-every-wordpress-user-needs-to-know

    If you have more questions please ask precise, single questions in new tickets and explain what you mean, don’t just throw in some screenshots. It’s almost impossible to understand what your question is, with this approach

    The question here was about adding css styles to manipulate svg icons and I believe that detail is solved?
    It’ll help you and others to be more precise and “on topic” in subsequent questions

    I also recommend trying out a few “how to” tutorials like above linked or as found in the internet for further understanding of how css works

    We’re happy to answer all kind of questions here but it’s hard to guess the questions based on screenshots without context inside a relatively unrelated topic 😃

    • This reply was modified 4 weeks ago by Beda.
Viewing 15 replies - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.