How to give Gradient to background border color using Css3 | Sanwebcorner

How to give Gradient to background border color using Css3

This post help you how to create gradient background border using css3 with the help of  border-image property. This is one of the simple way to add the gradient background using css3. The below image shows how the gradient looking for.

using the linear-gradient property you can mention the degree of the gradient and also starting background color and ending background color using this the gradient will appear in the border background.

In the below example i given different types of background colors with different types of the angle of the gradient. You can change those value as your wish. Below is the demo page is available check it out. I hope this post is very useful.

Html code for Gradient Border Background using css3

<h1>How to give Gradient to border using css3</h1>
<div class='bordered-gr-1'>1</div>
<div class='bordered-gr-2'>2</div>
<div class='bordered-gr-3'>3</div>
<div class='bordered-gr-4'>4</div>
<div class='bordered-gr-5'>5</div>
<br/>
<p style="margin-top:150px;">&nbsp;</p>
<p><a href="http://www.sanwebcorner.com"><h1>www.sanwebcorner.com</h1></a></p>

Css code for Gradient Border Background using css3

div {
    height: 100px; width: 100px;
    font-size: 50px;
    line-height: 100px;
    text-align: center;
    margin: 10px auto;
    background-clip: padding-box;
}
.bordered-gr-1 {
    float:left;
    margin:15px;
    border: 20px double pink;
    border-image: -webkit-linear-gradient(45deg,orange,yellow) 20 stretch;
}

.bordered-gr-2 {
    float:left;
    margin:15px;
    border: 20px double pink;
    border-image: -webkit-linear-gradient(90deg,green,yellow) 20 stretch;
}

.bordered-gr-3 {
    float:left;
    margin:15px;
    border: 20px double pink;
    border-image: -webkit-linear-gradient(120deg,red,yellow) 20 stretch;
}

.bordered-gr-4 {
    float:left;
    margin:15px;
    border: 20px double pink;
    border-image: -webkit-linear-gradient(180deg,pink,yellow) 20 stretch;
}

.bordered-gr-5 {
    float:left;
    margin:15px;
    border: 20px double pink;
    border-image: -webkit-linear-gradient(360deg,gray,black) 20 stretch;
}