inherit from another class

后端 未结 4 1403
生来不讨喜
生来不讨喜 2020-12-20 17:41

how is it possible to make one class inherit from another in the CSS file?

input.btn {
    border:1px solid #23458c;
    background:url(\'gfx/layout.btn_bg.p         


        
4条回答
  •  庸人自扰
    2020-12-20 18:07

    As an alternative to the accepted answer, you can also do the following with your CSS. The difference being that instead of using multiple class names where it will be used, this way uses multiple class names in the CSS to say "use this style and this style". Then, the reference (the input button in this case) only uses one class name.

    In the end, it accomplishes the same thing as the accepted answer.

    Note: I changed the value of the borders because I wanted to use values that were less subtle for the snippet.

    input.btn,
    input.btn_light {
      border: 2px solid red;
      background: url('gfx/layout.btn_bg.png');
      color: black;
      font-weight: bold;
      margin-right: 6px;
      padding: 1px 6px 2px 6px;
      cursor: pointer;
    }
    input.btn_light {
      border: 2px solid green;
      background: url('gfx/layout.btn_light_bg.png');
    }
    
      
      

提交回复
热议问题