Home >Web Front-end >HTML Tutorial >less hack 兼容_html/css_WEB-ITnose

less hack 兼容_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:37:211185browse

less hack 兼容

css做兼容是在所难免的,那么用less写css代码时怎样hack呢?倘若用css的方法直接在后面写上类似“\9”编译是要报错的。下面是我尝试的两个小方法仅供参考:

1.  先定义一个变量“/*\**/” 在hack时加上这个变量编译就不会报错:

@hack: ~"/*\**/";#box {     background-color@{hack}: blue\9; }

编译后的css代码为:

#box {    background-color/*\**/: blue\9;}

2.第二个方法原理与第一个类似,只是把hack符号“\9”自定义成变量,加到less代码的尾部,这样在编译时就能生成完整地css  hack代码,也不会报错。

@hack:~"\9";#box{    background-color:blue@hack;}

编译后的css代码是大家最熟悉的了:

#box{    background-color:blue\9;}

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn