wrap a .less css definitions in a namespace

前端 未结 5 582
情话喂你
情话喂你 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:17

    Here is how I did it, based on majgis's github fork above:

    bootstrap-ns.less:

    @import "namespace.less"
    .bs {
        #ns > .twitter;
        }
    

    namespace.less:

    #ns {
      .twitter(){
        @import "bootstrap.less";
      }
    }
    

    You then reference bootstrap-ns.less in your html page. This was tested with dotLESS.

提交回复
热议问题