elm-css:如何为ʻopacity`赋值 [英] elm-css: How to give a value to `opacity`
问题描述
我正在玩 elm-css
。
大多数事情都按我预期的那样工作。
但是我不能给 Css.opacity
函数正确的值。
I am playing around with elm-css
.
Most of the things work as I expect them.
But I am not able to give a correct value to the Css.opacity
function.
这里是我尝试过的:
Css.opacity 0.5
会给出错误:
Function `opacity` is expecting the argument to be:
Css.Number compatible
But it is:
Float
Css.Number
是类型别名,格式如下:
The Css.Number
is a type alias in the following form:
type alias Number compatible =
{ compatible | value : String, number : Compatible }
但我不知道如何为该值创建有效值 Css.opacity
函数...
But I don't understand how to create a valid value for the Css.opacity
function...
推荐答案
您可以创建输入使用无单位功能之一(例如 Css.int
或 Css)来实现
。例如: opacity
.num
You can create input for opacity
by using one of the "unitless" functions, like Css.int
or Css.num
. For example:
-- 42% opaque
translucent = Css.opacity (Css.num 0.42)
它是无单元的,因为opacity的CSS属性未定义 px
或百分比之类的单元。
It is "unitless" because the CSS property of opacity does not define a unit like px
or percent.
这篇关于elm-css:如何为ʻopacity`赋值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!