I want to set half blue and orange for border-color
of text
input.
I tried using a gradient but it doesn't work.
what is my code problem?
.search {
width: 550px;
height: 50px;
margin-left: 350px;
border-radius: 20px;
outline: none;
margin-top: 70px;
border: solid;
border-image: linear-gradient(to right, rgb(254, 113, 53) 50%, rgb(55, 154, 214) 50%);
font-size: 20px;
text-align: center;
transition: all 0.2s linear;
}
.search:hover,
.search:focus {
border: #4cbea5 solid;
}
<div>
<form method="post">
<input type="Search" class="search" placeholder="Search">
</form>
</div>
You need to specify the slice value inside border-image
like this :
.search {
width: 550px;
height: 50px;
border-radius: 20px;
outline: none;
margin-top: 70px;
border: solid;
border-image: linear-gradient(to right, rgb(254, 113, 53) 50%, rgb(55, 154, 214) 50%) 2;
font-size: 20px;
text-align: center;
}
<form method="post">
<input type="Search" class="search" placeholder="Search">
</form>
You can read more about border-image
By the way, you cannot use border-radius
with border-image
but you can achive the same using multiple background and by adjusting background-clip
. This will also allow you to have the hover behavior:
.search {
width: 550px;
height: 50px;
border-radius: 20px;
outline: none;
margin-top: 70px;
border: 2px solid transparent;
background:
linear-gradient(#fff,#fff) content-box,
linear-gradient(to right, rgb(254, 113, 53) 50%, rgb(55, 154, 214) 50%) border-box;
font-size: 20px;
text-align: center;
transition: all 0.2s linear;
}
.search:hover,
.search:focus {
border-color:#4cbea5;
}
<form method="post">
<input type="Search" class="search" placeholder="Search">
</form>
Related: Border Gradient with Border Radius