This jQuery function assigns an inline style of opacity:0.25
to each element with a class of grid-item
. How do I override that and add CSS of opacity:1
to the HTML element title
that is within grid-item
?
This is the function that assigns an inline style of opacity .25 to the selected items that have a class of grid-item
. It's part of a larger Isotope function that filters selected items.
// change opacity for selected/unselected items
var selectedClass = '.' + selectedCategory;
$items.filter(selectedClass).css({
opacity: 1
});
$items.not(selectedClass).css({
opacity: 0.25
});
This is the HTML that results:
<div class="grid-item" style="opacity: 0.25;">
<div class="title">
</div>
</div>
How do I add CSS of opacity:1
to a title
element? Either inline or in the style sheet?
Conceptually, this is what I need to do:
$items.not(selectedClass) $('.title').css('opacity',''1');
My question is how to add that to the function above? Or is there a better way?
Simply trying !important
in the style sheet
.grid-item .title {
opacity: 1 !important;
}
doesn't work.
Edit:
It appears that you can't change the opacity of a child element Disable opacity on child element when parent element has opacity unless you use background: rgba(255,255,255,0.8)
on the parent. But trying background: rgba(255,255,255,0.8)
in the function instead of opacity: 1
breaks it. How do I do this?:
// change opacity for selected/unselected items
var selectedClass = '.' + selectedCategory;
$items.filter(selectedClass).css({
background: rgba(255,255,255,0.8) //breaks
});
$items.not(selectedClass).css({
opacity: 0.25
});