How to make SVG in ::before pseudo-class clickable?2019 Community Moderator ElectionSetting CSS pseudo-class rules from JavaScriptHow to convert a PNG image to a SVG?CSS Pseudo-classes with inline stylesCSS3 :unchecked pseudo-classHow to convert a SVG to a PNG with Image Magick?make an html svg object also a clickable linkHow to change color of SVG image using CSS (jQuery SVG image replacement)?Is there a way to use SVG as content in a pseudo element :before or :afterAfter updating firefox 55 Inline images (img) is not rendering in HTML CANVAS through SVGHow to change color of SVGs on pseudo class element on hover?

How are passwords stolen from companies if they only store hashes?

ERC721: How to get the owned tokens of an address

Fastest way to pop N items from a large dict

Employee lack of ownership

If I can solve Sudoku, can I solve the Travelling Salesman Problem (TSP)? If so, how?

Have the tides ever turned twice on any open problem?

Counting models satisfying a boolean formula

Knife as defense against stray dogs

Why one should not leave fingerprints on bulbs and plugs?

Is "upgrade" the right word to use in this context?

Equivalents to the present tense

What is a ^ b and (a & b) << 1?

Adventure Game (text based) in C++

Why does overlay work only on the first tcolorbox?

How difficult is it to simply disable/disengage the MCAS on Boeing 737 Max 8 & 9 Aircraft?

Why do tuner card drivers fail to build after kernel update to 4.4.0-143-generic?

The German vowel “a” changes to the English “i”

Describing a chess game in a novel

Planetary tidal locking causing asymetrical water distribution

Is there a hypothetical scenario that would make Earth uninhabitable for humans, but not for (the majority of) other animals?

Why did it take so long to abandon sail after steamships were demonstrated?

As a new Ubuntu desktop 18.04 LTS user, do I need to use ufw for a firewall or is iptables sufficient?

Recruiter wants very extensive technical details about all of my previous work

Is honey really a supersaturated solution? Does heating to un-crystalize redissolve it or melt it?



How to make SVG in ::before pseudo-class clickable?



2019 Community Moderator ElectionSetting CSS pseudo-class rules from JavaScriptHow to convert a PNG image to a SVG?CSS Pseudo-classes with inline stylesCSS3 :unchecked pseudo-classHow to convert a SVG to a PNG with Image Magick?make an html svg object also a clickable linkHow to change color of SVG image using CSS (jQuery SVG image replacement)?Is there a way to use SVG as content in a pseudo element :before or :afterAfter updating firefox 55 Inline images (img) is not rendering in HTML CANVAS through SVGHow to change color of SVGs on pseudo class element on hover?










0















I have a breadcrumb that lists the page's hierarchy path. I hid the first anchor tag & changed the anchor tag ::before pseudo-class to an SVG of a small house like so:



li:first-child a 
display: none;


li:first-child::before
color: transparent;
content: '';
display: block;
width: rem(16px);
height: rem(16px);
position: relative;
top: rem(2px);
margin: 0;
background-image: url("../images/breadcrumb-image.svg");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
&:hover
color: transparent;




I got the desire effect but the SVG is not clickable to return to the home page. Any solutions for this? I don't mind whether CSS or JS.



This is the image so it gives you an idea:
enter image description here



Thanks in advance!










share|improve this question


























    0















    I have a breadcrumb that lists the page's hierarchy path. I hid the first anchor tag & changed the anchor tag ::before pseudo-class to an SVG of a small house like so:



    li:first-child a 
    display: none;


    li:first-child::before
    color: transparent;
    content: '';
    display: block;
    width: rem(16px);
    height: rem(16px);
    position: relative;
    top: rem(2px);
    margin: 0;
    background-image: url("../images/breadcrumb-image.svg");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    &:hover
    color: transparent;




    I got the desire effect but the SVG is not clickable to return to the home page. Any solutions for this? I don't mind whether CSS or JS.



    This is the image so it gives you an idea:
    enter image description here



    Thanks in advance!










    share|improve this question
























      0












      0








      0


      1






      I have a breadcrumb that lists the page's hierarchy path. I hid the first anchor tag & changed the anchor tag ::before pseudo-class to an SVG of a small house like so:



      li:first-child a 
      display: none;


      li:first-child::before
      color: transparent;
      content: '';
      display: block;
      width: rem(16px);
      height: rem(16px);
      position: relative;
      top: rem(2px);
      margin: 0;
      background-image: url("../images/breadcrumb-image.svg");
      background-repeat: no-repeat;
      background-size: cover;
      background-position: center;
      &:hover
      color: transparent;




      I got the desire effect but the SVG is not clickable to return to the home page. Any solutions for this? I don't mind whether CSS or JS.



      This is the image so it gives you an idea:
      enter image description here



      Thanks in advance!










      share|improve this question














      I have a breadcrumb that lists the page's hierarchy path. I hid the first anchor tag & changed the anchor tag ::before pseudo-class to an SVG of a small house like so:



      li:first-child a 
      display: none;


      li:first-child::before
      color: transparent;
      content: '';
      display: block;
      width: rem(16px);
      height: rem(16px);
      position: relative;
      top: rem(2px);
      margin: 0;
      background-image: url("../images/breadcrumb-image.svg");
      background-repeat: no-repeat;
      background-size: cover;
      background-position: center;
      &:hover
      color: transparent;




      I got the desire effect but the SVG is not clickable to return to the home page. Any solutions for this? I don't mind whether CSS or JS.



      This is the image so it gives you an idea:
      enter image description here



      Thanks in advance!







      svg breadcrumbs pseudo-class






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 6 at 20:32









      Manuel AbascalManuel Abascal

      57210




      57210






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I have found a way to make the SVG on a ::before pseudo-class clickable through jQuery like so:



          SCSS Code:



          This is the styling to hide the anchor tag & add an SVG to the anchor tag before pseudo-class.



          li:first-child a 
          display: none;

          li:first-child::before
          color: transparent;
          content: '';
          cursor: pointer;
          display: block;
          width: rem(16px);
          height: rem(16px);
          position: relative;
          top: rem(2px);
          margin: 0;
          background-image: url("../images/breadcrumb-image.svg");
          background-repeat: no-repeat;
          background-size: cover;
          background-position: center;
          &:hover
          color: transparent;
          cursor: pointer;




          JavaScript Code:



           //Store the href attribute(the link was already pointing to the home page) of the anchor tag in a variable
          var breadcrumbHomeLink = $('.breadcrumb__list--item:first-child a').attr('href');

          //Store the SVG with ::before pseudo-class in variable
          var breadcrumbSVG = $('.breadcrumb__list--item:first-child').before();

          //Make Breadcrumb SVG clickable & redirect to home page
          breadcrumbSVG.on('click', function()
          location.href = breadcrumbHomeLink;
          );





          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031706%2fhow-to-make-svg-in-before-pseudo-class-clickable%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I have found a way to make the SVG on a ::before pseudo-class clickable through jQuery like so:



            SCSS Code:



            This is the styling to hide the anchor tag & add an SVG to the anchor tag before pseudo-class.



            li:first-child a 
            display: none;

            li:first-child::before
            color: transparent;
            content: '';
            cursor: pointer;
            display: block;
            width: rem(16px);
            height: rem(16px);
            position: relative;
            top: rem(2px);
            margin: 0;
            background-image: url("../images/breadcrumb-image.svg");
            background-repeat: no-repeat;
            background-size: cover;
            background-position: center;
            &:hover
            color: transparent;
            cursor: pointer;




            JavaScript Code:



             //Store the href attribute(the link was already pointing to the home page) of the anchor tag in a variable
            var breadcrumbHomeLink = $('.breadcrumb__list--item:first-child a').attr('href');

            //Store the SVG with ::before pseudo-class in variable
            var breadcrumbSVG = $('.breadcrumb__list--item:first-child').before();

            //Make Breadcrumb SVG clickable & redirect to home page
            breadcrumbSVG.on('click', function()
            location.href = breadcrumbHomeLink;
            );





            share|improve this answer





























              0














              I have found a way to make the SVG on a ::before pseudo-class clickable through jQuery like so:



              SCSS Code:



              This is the styling to hide the anchor tag & add an SVG to the anchor tag before pseudo-class.



              li:first-child a 
              display: none;

              li:first-child::before
              color: transparent;
              content: '';
              cursor: pointer;
              display: block;
              width: rem(16px);
              height: rem(16px);
              position: relative;
              top: rem(2px);
              margin: 0;
              background-image: url("../images/breadcrumb-image.svg");
              background-repeat: no-repeat;
              background-size: cover;
              background-position: center;
              &:hover
              color: transparent;
              cursor: pointer;




              JavaScript Code:



               //Store the href attribute(the link was already pointing to the home page) of the anchor tag in a variable
              var breadcrumbHomeLink = $('.breadcrumb__list--item:first-child a').attr('href');

              //Store the SVG with ::before pseudo-class in variable
              var breadcrumbSVG = $('.breadcrumb__list--item:first-child').before();

              //Make Breadcrumb SVG clickable & redirect to home page
              breadcrumbSVG.on('click', function()
              location.href = breadcrumbHomeLink;
              );





              share|improve this answer



























                0












                0








                0







                I have found a way to make the SVG on a ::before pseudo-class clickable through jQuery like so:



                SCSS Code:



                This is the styling to hide the anchor tag & add an SVG to the anchor tag before pseudo-class.



                li:first-child a 
                display: none;

                li:first-child::before
                color: transparent;
                content: '';
                cursor: pointer;
                display: block;
                width: rem(16px);
                height: rem(16px);
                position: relative;
                top: rem(2px);
                margin: 0;
                background-image: url("../images/breadcrumb-image.svg");
                background-repeat: no-repeat;
                background-size: cover;
                background-position: center;
                &:hover
                color: transparent;
                cursor: pointer;




                JavaScript Code:



                 //Store the href attribute(the link was already pointing to the home page) of the anchor tag in a variable
                var breadcrumbHomeLink = $('.breadcrumb__list--item:first-child a').attr('href');

                //Store the SVG with ::before pseudo-class in variable
                var breadcrumbSVG = $('.breadcrumb__list--item:first-child').before();

                //Make Breadcrumb SVG clickable & redirect to home page
                breadcrumbSVG.on('click', function()
                location.href = breadcrumbHomeLink;
                );





                share|improve this answer















                I have found a way to make the SVG on a ::before pseudo-class clickable through jQuery like so:



                SCSS Code:



                This is the styling to hide the anchor tag & add an SVG to the anchor tag before pseudo-class.



                li:first-child a 
                display: none;

                li:first-child::before
                color: transparent;
                content: '';
                cursor: pointer;
                display: block;
                width: rem(16px);
                height: rem(16px);
                position: relative;
                top: rem(2px);
                margin: 0;
                background-image: url("../images/breadcrumb-image.svg");
                background-repeat: no-repeat;
                background-size: cover;
                background-position: center;
                &:hover
                color: transparent;
                cursor: pointer;




                JavaScript Code:



                 //Store the href attribute(the link was already pointing to the home page) of the anchor tag in a variable
                var breadcrumbHomeLink = $('.breadcrumb__list--item:first-child a').attr('href');

                //Store the SVG with ::before pseudo-class in variable
                var breadcrumbSVG = $('.breadcrumb__list--item:first-child').before();

                //Make Breadcrumb SVG clickable & redirect to home page
                breadcrumbSVG.on('click', function()
                location.href = breadcrumbHomeLink;
                );






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 9 at 22:36

























                answered Mar 9 at 22:21









                Manuel AbascalManuel Abascal

                57210




                57210





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031706%2fhow-to-make-svg-in-before-pseudo-class-clickable%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

                    Алба-Юлія

                    Захаров Федір Захарович