CSS: Style external links

前端 未结 8 1821
甜味超标
甜味超标 2021-01-30 16:55

I want to style all external links in my website (Wordpress). I\'m trying with:

.post p a[href^=\"http://\"]:after

But Wordpress put the entire

8条回答
  •  心在旅途
    2021-01-30 17:45

    I like the approach @henryscat shared, but not being an SVG expert I struggled to change the icon. To make it easier for me, I removed the mask and created the icon using lines only. The comment in front of the icon definition describes which is which part of the icon.

    a[target="_blank"]::after {
        content: '';
        background: no-repeat var(--icon-external-link);
        padding-right: 1em;
    }
    
    :root {
        /*
        line left
        line right
        line bottom
        line top
        arrow left
        arrow right
        arrow diagonal
        */
        --icon-external-link: url('data:image/svg+xml,\
         \
             \
                 \
                 \
                 \
                 \
                 \
                 \
                 \
             \
        ');
    }
    

提交回复
热议问题