wrap a .less css definitions in a namespace

前端 未结 5 600
情话喂你
情话喂你 2020-12-24 07:31

I wanted to use twitter bootstrap CSS only in a specific element in my web page.

I tried to do it like in code below. But after compiling this to a css file nothing

5条回答
  •  忘掉有多难
    2020-12-24 08:20

    This is how I have done it. This takes place in the root of the bootstrap folder that is downloaded, or cloned from git.

    ## ./less/namespace.css (New file)
    
    #ns {
      .twitter() {
        @import "less/bootstrap.less";
      }
    }
    
    ## ./style.less
    
    @import "less/namespace.less";
    
    .namespace {
      #ns > .twitter;
    }
    

    Then run less style.less > style.css

提交回复
热议问题