Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: Stripe with multiple colors

Tags:

css

border

I have a navigation bar and want it to have a border at the bottom like a multi-colored stripe. For example, Google uses a multi-colored stripe like this:

Google multi-color stripe.

Could I do this in pure CSS, or would I have to use something like border-image?

like image 835
beakr Avatar asked Feb 13 '26 12:02

beakr


1 Answers

You can do this with a linear gradient. In addition to just plain colors, you can do gradients for each stop. For google's own stripe, the color stops would look like this, CSS color names used for clarity:

background-image: linear-gradient(
  to right, 
  blue,
  blue 25%,
  red 25%,
  red 50%,
  orange 50%,
  orange 75%,
  green 75%);

You can play with background-position and background-size to make it smaller than just the full header size, or put it into an :after / :before element and change the size on that element.

Example of color stops with gradient:

http://codepen.io/tholex/pen/nCzLt

like image 50
Olex Ponomarenko Avatar answered Feb 17 '26 14:02

Olex Ponomarenko



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!