helpme
helpme

Reputation: 23

Background Color Highlight

How to achieve this one : https://i.sstatic.net/Q3aH4.jpg

My sample Codes :

h1 {
    position: relative;
    color: #FFF;
}

h1:after {
    content: attr(data-content);
    position: absolute;
    color: #000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: red;
}
<h1 data-content="Hello world!">Hello world!</span>

Upvotes: 1

Views: 1737

Answers (1)

nad
nad

Reputation: 1100

You can use the CSS linear-gradient function to achieve the desired effect.

body {
  background-color: #1D1D31;
  padding: 50px 50px;
}
h1 {
  display: inline-block;
  position: relative;
  padding: 10px 30px;
  color: #fff;
  background: linear-gradient(90deg,#314563 0,#5d6d85 70%,#8292a1 100%)
}
<h1>Hello world!</span>

Upvotes: 3

Related Questions