categories – display category with background color

Question

I would add the category slug as a class to each category link, and change your class name to be more specific so other CSS doesn’t conflict on accident:

<div class="category-link">
    <a href="#" class="<?= $cats[0]->slug ?>"><?= $cats[0]->name ?></a>
</div>

Then call the class with CSS:

.category-link .food {
    background-color: red;
}

0
medempire 4 weeks 2022-07-20T08:14:23-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse