Disclaimer: I know similar questions have been posted a lot of times, but after a lot of research I wasn't able to find a solution to this.
Hello, on the website I'm building there is a menu with filtering options. These options are composed of "a" tags and an "hr" underneath. The idea here is to increase the size of the before part of the "hr" when an option is pressed.
HTML Code:
<div style="padding-left: 15px; width: 100%">
<a class="style-filter-item-options" style="color: #000 !important;" id="filter-option-id-latest">Latest</a>
<a class="style-filter-item-options" id="filter-option-id-most-views">Most Views</a>
<a class="style-filter-item-options" id="filter-option-id-random">Random</a>
<hr id="video-index-hr-id" class="style-menus-hr" style="margin-bottom: 1.25rem; width: 100%; margin-left: 0; margin-right: 0; padding-right: 0;">
</div>
Relevant CSS:
.style-menus-hr {
background-color: #c4c4c4 !important;
border: none !important;
display: block !important;
height: 1px !important;
overflow: visible !important;
position: relative !important;
max-width: 96% !important;
}
.style-menus-hr:before {
background-color: #ff5c33 !important;
content: '' !important;
display: block !important;
height: 1px !important;
left: 0 !important;
position: absolute !important;
width: 5% !important;
z-index: 1 !important;
}
JQuery representation example:
<script>
$("#filter-option-id-latest").click(function(){
$("#video-index-hr-id before").css('width', '5%');
});
$("#filter-option-id-most-views").click(function(){
$("#video-index-hr-id before").css('width', '15%');
});
</script>
Image representation:
on the :before pseudo-class – RaulRohjans Aug 20 '21 at 22:00