What does & do in css

后端 未结 2 469
无人共我
无人共我 2021-01-28 14:51

I am looking at some legacy code and found something like below in the css file:

.user_modal {
  width: auto;
  height\" auto;
  &.modal,
  &.fade.in
  {         


        
2条回答
  •  [愿得一人]
    2021-01-28 15:19

    You're probably experienced with SASS selector. The ampersand & in sass is used to refer to the parent selector. So in your case & will refer to parent selector which is .user_modal

    So &.modal which will be converted to CSS and become .user_modal.modal

    so it'll match:

    
    

    the same way for &.fade.in which will match

    So finally it's just become normal CSS after you've converted it:

    .user_modal.modal , .user_modal.fade.in {
        margin-top:0;
        margin-left:0;
        top:83px;
    }
    

提交回复
热议问题