头图
radial-gradient is a cool css property. We can use it to draw a very sensible gradient background to the element. If you don't use it often, you'll find that its syntax is not easy to remember, and is slightly more complicated than linear-gradient(). This article takes you to appreciate its charm through 2 examples.

gradient background color

 <div class="hire_wrapper"></div>
 .hire_wrapper {
  background: radial-gradient(circle at 22% 5%, rgb(85, 55, 101), rgb(30, 38, 74) 76%);
  height: 100vh;
}

It can be rendered in the browser with the following background gradient:
radial-gradient

Online demo address

Highlight text

 <h1>Syncopate</h1>
 @import url(https://fonts.googleapis.com/css?family=Syncopate);

body {
  height: 100vh;
  background: radial-gradient(
    circle closest-corner at center 125px,
    #222,
    black 40%
  ) no-repeat;
  text-align: center;
}
h1 {
  display: inline-block;
  padding-top: 100px;
  font-family: 'Syncopate', sans-serif;
  text-transform: uppercase;
  background: radial-gradient(
    circle farthest-corner at center center,
    #ccc,
    #333
  ) no-repeat;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

Renders the following result:
bg

Online demo address

Background follow mouse gradient animation

If you add some mouse-in events, you can make more awesome effects, such as this:
sun rise

sunrise

Reference link

The article was first published on IICCOM-personal blog "css radial-gradient drawing gradient background"


来了老弟
508 声望31 粉丝

纸上得来终觉浅,绝知此事要躬行