DEV Community

Discussion on: How to change background image opacity in CSS

Collapse
 
adityamitra profile image
Aditya Mitra

How will you change the background opacity of an image html element inside a div container only which also contains a header? The header should not be affected

Collapse
 
heyprotagonist profile image
Anguram Shanmugam

you have two ways,

  • seperate with div elements
  • using css access the correct child element .i.e using n-th-child-element
Collapse
 
thecodercoder profile image
Jessica Chan

If it's an element, you can adjust the opacity of that without affecting other sibling elements

Collapse
 
adityamitra profile image
Aditya Mitra

You mean changing the opacity of the img element only without touching the header.
Yeah, that will work!

Thread Thread
 
thecodercoder profile image
Jessica Chan

oop yes, I typed in "img" with brackets so it got messed up 😂