CSS Grayscale Hover Effects

Web Design & Web Development

Demo

Sponsored links

 

Code

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>CSS Grayscale Hover Effects</title>
    <link rel="stylesheet" type="text/css" href="https://demo.plantpot.works/assets/css/normalize.css">
    <link rel="stylesheet" href="https://use.typekit.net/opg3wle.css">
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
    <div id="container">
      <img src="css3.svg" alt="">
      <h1>Grayscale Hover Effects</h1>
    </div>
  </body>
</html>

CSS

@charset "utf-8";
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
}
body {
  background-color: #e9e3d1;
  font-family: futura-pt, sans-serif;
  -webkit-tap-highlight-color: rgba(0,0,0,0);
}
#container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
}
img {
  width: 100px;
  filter: grayscale(1);
}
img:hover {
  filter: grayscale(0);
}
h1 {
  margin: 20px 0 0;
  color: #3d3935;
  font-size: 2.5rem;
  text-align: center;
}
@media screen and (max-width: 480px) {
  h1 {
    margin-top: 10px;
    font-size: 1.75rem;
  }
}