當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Less ispixel()用法及代碼示例

Less ispixel() 函數將一個值作為參數,如果該值是一個像素,則返回 TRUE,否則返回 FALSE。

isurl() 函數示例

下麵舉一個例子來演示Less文件中isurl()函數的用法。

創建一個名為 "simple.less" 的 Less 文件,代碼如下:

少文件:simple.less

div {
    font:       ispixel(#ff0);          
    background: ispixel(blue);    
    border:     ispixel("string");  
    font:       ispixel(1234);    
    background: ispixel(56px);    
    border:     ispixel(7.8%);          
    border:     ispixel(keyword);               
}

現在打開 node.js 命令提示符並執行以下代碼:lessc simple.less simple.css

Less ispixel function1

這將編譯 "simple.less" 文件。將生成名為 "simple.css" 的 CSS 文件。

例如:

Less ispixel function2

輸出:

Less ispixel function3
div {
  background:false;
  font:false;
  background:true;
  border:false;
}




相關用法


注:本文由純淨天空篩選整理自 Less ispixel()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。