Class active is not working when used with tag
Class active is not working when used with <a></a> tag
Good day to all, I'd to ask why class="active"
is not working when used as an attribute of an a
tag, for example:
class="active"
a
<a class="p-2 text-dark Request::is('/') ? "active" :""" href="/">Main Menu</a>
Bad type of question, how can we know why it's not working... You probably don't have .active anywhere in your included css files or you didn't include css files that contain that class.
– Imaginaroom
Sep 13 '18 at 7:26
what do you see in browser inspector?
– Aleksandrs
Sep 13 '18 at 7:33
1 Answer
1
Hope this works,
Request::path() == '/' ? 'active' : ''
hi dude I have tried your code but no result I just wanted to ensure that if I go for example to home page which is '/' then in navbar home should be highlighted. Usually active is used with li but can I use active with a tag
– Mirich
Sep 13 '18 at 7:31
I need to review your CSS before answer this. Because maybe in your CSS, 'active' is only defined for used with <li> only?
– Ashok Gujjar
Sep 13 '18 at 7:34
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
This seems to be more of a html/css question than php or laravel related, unless your "active" class simply isn't inserted. In order to get people with the right expertise to read this question, you might want to consider changing the tags.
– Stratadox
Sep 13 '18 at 7:26