php – trying to put an active hover to my custom nav category buttons
Question
I have a custom category buttons which each of buttons link and echoed the specific category at the same page. my goal is to put a active background hover color on the active link. here is my code so far:
<?php
$args = array(
'orderby' => 'slug',
'order' => 'ASC',
'parent' => 0,
'hide_empty' => false
);
$categories = get_categories( $args );
foreach( $categories as $category ){
echo '<li><a class="ctg" href="' . get_category_link( $category->term_id ) .' ">' . $category->name . '</a></li>';
}
?>
and my css:
.ctg:hover {
background: #A6EBF2;
}
.ctg:active {
background-color: #A6EBF2;
}
any help is appreciated.
0
2 years
2021-04-07T01:50:40-05:00
2021-04-07T01:50:40-05:00 0 Answers
0 views
0
Leave an answer