简体   繁体   中英

How would I write the following css into valid sass, scss?

I have the following css which I want to convert into valid scss sass:

        .my-class>li.active>a,
        .my-class>li.active>a:hover,
        .my-class>li.active>a:focus {
           color: #555;
           background-color: #fff;
        }

I tried as per below, but it did not give me the exact results:

  .myclass {
     .li {
        &.active {
           color: #555;
           background-color: #fff;
           &:hover, &:focus {
              color: #555;
              background-color: #fff;
           }
        }
     }
  }

try in this way:

 .myclass {
     > li.active {
        > a, > a:hover, > a:focus {
            color: #555;
            background-color: #fff;              
        }
     }
  }

The resulting output (tested on sassmeister ) is

.myclass > li.active > a,
.myclass > li.active > a:hover, 
.myclass > li.active > a:focus {
  color: #555;
  background-color: #fff;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM