S
S
Sergey Goryachev2016-10-22 15:52:04
css
Sergey Goryachev, 2016-10-22 15:52:04

Inheritance in SCSS of one property?

Learning sass-scss.ru/guide Here
is an example:

.message {
  border: 1px solid #ccc;
  padding: 10px;
  color: #333;
}
.success {
  @extend .message;
  border-color: green;
}

Everything is clear here.
But what if I need to enjoy not the whole block, but only a couple of properties?
.message {
  border: 1px solid #ccc;
  padding: 10px;
  color: #333;
}
.message2 {
  border: 1px solid #ccc;
  padding: 10px;
}

Or I will give a more specific example of what is needed now.
.header {
    background: transparentize($cwhite,0.15);
    position: fixed;
    width: 100%;
    z-index: 100;
    &:after {
        content: '';
        position: absolute;
        background: transparentize($cwhite,0.15);
        width: 100%;
        left: 0;
        bottom: -50px;
        height: 50px;
        border-bottom-right-radius: 50%;
        border-bottom-left-radius: 50%;
    }
}

Now we actually have to duplicate the same entry background: transparentize($cwhite,0.15); .
Is it possible to somehow inherit the color and transparency from the header at once?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey delphinpro, 2016-10-22
@webirus

%bgtrans {
  background: transparentize($cwhite,0.15);
}
.header {
  @extend %bgtrans;
  &:after {
      @extend %bgtrans;
  }
}

I
iBird Rose, 2016-10-22
@iiiBird

no way. create another element and inherit it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question