Saurabh Singh Mehra
Saurabh Singh Mehra

Reputation: 214

How to make a double color single border using css?

Guys actually I need help to make a single border double colored. It means a single line 25 % of red and other 75% of blue color using CSS.

My non-working code:

element { 
  border-bottom:2px solid red;
  position:relative;
  z-index:999;
  opacity:1;

I think it can be possible by :before and :after pseudo elements.

Upvotes: 0

Views: 173

Answers (1)

KittMedia
KittMedia

Reputation: 7466

HTML:

<div class="element"></div>

CSS:

.element {
    border-bottom: 2px solid #00f;
    position: relative;
}

.element::before {
    background-color: #f00;
    content: "";
    height: 2px;
    position: absolute;
    width: 25%;
}

Demo: JSFiddle

Upvotes: 2

Related Questions