0
Good afternoon! I have a filter on my site that shows certain partners of my company, but whenever I select a filter that has few logos of the partners the Divs are all left.
I need a function that changes a specific attribute of my css when the person makes a filter so the images are centered.
Example: Clicked on filter by "Security" segment, be changed in CSS the attribute "width: 16.6%" to "width: 50.0%".
I am layman in programming yet so it was myself who tried to make the script below, I’m not sure if the reasoning is right.
Index (filter button):
<li><a href="#" data-filter=".seguranca">Segurança</a></li>
CSS (main.css):
#portfolio .portfolio-item {width: 16.6%;}
Script:
<script>
function(teste)
if (data-filter == .seguranca) {set style '.\main.css' = '.portfolio-item', width=50.0%}
</script>
Image (Partner):
<div class="portfolio-item seguranca">
<div class="portfolio-item-inner">
<img src="./images/imagem.png">
</div>
</div>
I managed to make the Width change work, but it is only applied in the first image of the filter, the others continue with the 16.6%
– Roger Windberg
@Rogerwindberg is pq to get more than one element you need to use a querySelectorAll, and then make a foreach. I edited the look code there
– hugocsl