unitless() 函数相对来说简单明了些,只是用来判断一个值是否带有单位,如果不带单位返回的值为 true,带单位返回的值为 false:

>> unitless(100)
true
>> unitless(100px)
false
>> unitless(100em)
false
>> unitless(100%)
false
>> unitless(1 /2 )
true
>> unitless(1 /2 + 2 )
true
>> unitless(1px /2 + 2 )
false
// 判断如果没有单位则加上单位"px"
@mixin adjust-location($x, $y) {
@if unitless($x) {
$x: 1px * $x;
}
@if unitless($y) {
$y: 1px * $y;
}
position: relative;
left: $x;
top: $y;
} .botton{
@include adjust-location(20px, 30);
}

最新文章

  1. nodejs:连接数据库SqlServer,mssql模块
  2. 第 24 章 CSS3 变形效果[下]
  3. centos7下使用yum安装mysql数据库以及设置远程访问
  4. iOS-appDelegate 生命周期
  5. Android之动态图片
  6. websphere性能设置和日常维护
  7. 写代码要注意细节,无谓的找前台bug
  8. C#/winform 旅游管理信息系统
  9. 手动修复IAT
  10. VsCode 附加Chorme调试TS方法
  11. override和重载的区别
  12. Golang常用包
  13. 2018-2019-2 20175224 实验二《Java面向对象程序设计》实验报告
  14. Why the Anaconda command prompt is the first choice in windows?
  15. git 语法
  16. UIView常见方法
  17. Objective-C 中的协议(@protocol)和接口(@interface)的区别
  18. 使用scrapy框架爬取自己的博文(3)
  19. Dep数据发布,推送
  20. cocos2d-x(十一)Lua开发飞机大战-6-加入子弹

热门文章

  1. 【leetcode】1038. Binary Search Tree to Greater Sum Tree
  2. Xcode模拟器快捷键
  3. Linux的磁盘分区
  4. Mac终端的Cocoapods创建自己的私有库和公有库
  5. Xcode编辑器之快捷键的使用
  6. 【HDOJ6695】Welcome Party(multiset)
  7. 【POJ2893&HDOJ6620】M × N Puzzle(n*m数码判定)
  8. 【HDOJ6614】AND Minimum Spanning Tree(签到)
  9. git 代码强行提交
  10. Power Strings POJ - 2406