- This topic has 3 replies, 2 voices, and was last updated 4 months, 3 weeks ago by
Leo.
-
AuthorPosts
-
October 5, 2020 at 5:38 am #1472889
André
I want to add an animated underline for text links only. I used this CSS:
.entry-content a { text-decoration:none; display: inline-block; color:black; } .entry-content a:after { content: ''; display: block; height: 3px; width: 0; background: transparent; transition: width .5s ease, background-color .5s ease; /* .5 seonds for changes to the width and background-color */ -webkit-transition: width .5s ease, background-color .5s ease; /* Chrome and Safari */ -moz-transition: width .5s ease, background-color .5s ease; /* FireFox */ } .entry-content a:hover:after { width: 100%; background: #d11b1b; }
However, this also adds the effect to images, buttons, and headlines as well. I also tried to put it in its own class, but I cannot add the class to all text links, e.g. taxonomies/categories. If I try to remove it from buttons with
:not(.buttons)
, it doesn’t work anymore on any link.Also
.entry-content
doesn’t seem to fit, because it does not work on archive pages either. If I use it for all anchors, it breaks all links because it will affect every link on the site.How can I target all text links, so, links in blocks, categories, footer menu, taxonomies?
I want all other links in the main menu, buttons, headlines to stay as they are.October 5, 2020 at 9:16 am #1473368Leo
StaffCustomer SupportHi there,
There isn’t an easy solution for this unfortunately.
I also tried to put it in its own class, but I cannot add the class to all text links, e.g. taxonomies/categories.
I think adding class to the links you want the effect is the best solution. Then you will need to write more CSS to target the taxonomies and categories separately.
I don’t think it’s possible to use one CSS selector to take care of all the conditionals you need.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 6, 2020 at 1:06 am #1474126André
Unfortunately, adding a separate class to all the links is impossible because some links are generated by plugins like WP Show Posts Pro for example. However, I found a solution that works for me. It is a mixture of class and selectors. I use RankMath on my site and that automatically creates a class to links
.rank-math-link
. On the other hand, I can easily select the links from WP Show Posts Pro withdiv.wp-show-posts-inner > div.wpsp-content-wrap > header > div a
.That keeps the additional CSS to a minimum.
October 6, 2020 at 8:21 am #1474833Leo
StaffCustomer SupportGlad to hear 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.