0

I have two CSSs.

The first one is this:

#breadcrumbs-cool a::before{
  content: "";
  position: absolute;
  top: 50%;
  margin-top: -1.5em;
  border-width: 1.5em 0 1.5em 1em;
  border-style: solid;
  border-color: #ccc #ccc #ccc transparent;
  left: -1em;
}

Then the next

#breadcrumbs-cool a.disable::before{
  content: "";
  position: absolute;
  top: 50%;
  margin-top: -1.5em;
  border-width: 1.5em 0 1.5em 1em;
  border-style: solid;
  border-color: #eee #eee #eee transparent;
  left: -1em;
}

Notice that the only difference are class directive

a::before 
a.disable::before

And border color: #ccc versus #eee. How can I refactor these two CSS?

2
  • 1
    remove everything but the border-color in the second rule Commented Oct 23, 2015 at 7:45
  • 1
    Just reuse the selectors and add in your desired styling? Commented Oct 23, 2015 at 7:46

1 Answer 1

5

You need to keep this as is:

#breadcrumbs-two a::before{
  content: "";
  position: absolute;
  top: 50%;
  margin-top: -1.5em;
  border-width: 1.5em 0 1.5em 1em;
  border-style: solid;
  border-color: #ccc #ccc #ccc transparent;
  left: -1em;
}

And then just overwrite the part you want to be specific when disable class is present

#breadcrumbs-two a.disable::before{
  border-color: #eee #eee #eee transparent;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.