Rapturezone

  • Resources
  • Blog
  • About Us
  • Privacy Policy

How to Change the Opacity of an Element Using CSS

April 17 by www

Being fairly new to CSS. Today I had the need to have a image button do “something different”. I wanted something to change when the mouse hovers over it.

My intention was to draw the eye to the button/image.

As with most problem. There are always multiple way to solve them.
Here is one way of accomplishing it with CSS.

HTML

Before Change

<img src=”pic.jpg”>

After Change

<img class=”img_opac”src=”pic.jpg”>

CSS

.img_opac
{
opacity: 0.4;
}

Conclusion

Make sure you mark it up as a class and not an id.
You will be using images many more times than one.

 

 

 

Filed Under: How To Tagged With: CSS

Recent Posts

  • Alternative Android Apps
  • Web Scraping with Python and Beautiful Soup Example IMDB Top 250
  • Web Scraping with Python and Beautiful Soup
  • Pi Pico Mouse Jiggler
  • JellyFin Docker Container

Recent Comments

    Archives

    • September 2021
    • August 2021
    • July 2021
    • January 2021
    • September 2020
    • August 2020
    • June 2020
    • May 2020
    • December 2019
    • November 2019
    • November 2017
    • July 2017
    • January 2017
    • January 2016
    • December 2015
    • September 2015
    • April 2015
    • March 2015
    • November 2014

    Categories

    • Definitions
    • How To
    • Resources
    • Uncategorized

    Meta

    • Log in
    • Entries feed
    • Comments feed
    • WordPress.org
    Google+

    Copyright © 2025 · eleven40 Pro Theme on Genesis Framework · WordPress · Log in