Sass-unitless()函数
2024-09-06 01:05:57
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);
}
最新文章
- nodejs:连接数据库SqlServer,mssql模块
- 第 24 章 CSS3 变形效果[下]
- centos7下使用yum安装mysql数据库以及设置远程访问
- iOS-appDelegate 生命周期
- Android之动态图片
- websphere性能设置和日常维护
- 写代码要注意细节,无谓的找前台bug
- C#/winform 旅游管理信息系统
- 手动修复IAT
- VsCode 附加Chorme调试TS方法
- override和重载的区别
- Golang常用包
- 2018-2019-2 20175224 实验二《Java面向对象程序设计》实验报告
- Why the Anaconda command prompt is the first choice in windows?
- git 语法
- UIView常见方法
- Objective-C 中的协议(@protocol)和接口(@interface)的区别
- 使用scrapy框架爬取自己的博文(3)
- Dep数据发布,推送
- cocos2d-x(十一)Lua开发飞机大战-6-加入子弹
热门文章
- 【leetcode】1038. Binary Search Tree to Greater Sum Tree
- Xcode模拟器快捷键
- Linux的磁盘分区
- Mac终端的Cocoapods创建自己的私有库和公有库
- Xcode编辑器之快捷键的使用
- 【HDOJ6695】Welcome Party(multiset)
- 【POJ2893&;HDOJ6620】M × N Puzzle(n*m数码判定)
- 【HDOJ6614】AND Minimum Spanning Tree(签到)
- git 代码强行提交
- Power Strings POJ - 2406