Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the opacity of the border without changing its color

Tags:

html

css

sass

I'm going to change opacity of input's border when it's disabled using SCSS. But border color is coming from variable:

$borderColor: #5985dc;

.my-input {
  border: 1px solid $borderColor;
}
.my-input:disabled {
  border-color: ???;
}

... or is there any way to change the color to half-transparent version?

like image 861
Si7ius Avatar asked Sep 21 '25 10:09

Si7ius


1 Answers

You can use Sass's rgba() function. It can take a hex colour value and an opacity value, and convert it to RGBA:

$borderColor: #5985dc;

.my-input {
  border: 1px solid $borderColor;
}
.my-input:disabled {
  border-color: rgba($borderColor, 0.5);
}
like image 100
Arthur Avatar answered Sep 23 '25 00:09

Arthur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!