The SCSS function responsive-value is created to facilitate working with responsive CSS property values without using media queries.
@function responsive-value(
$start-value,
$end-value,
$start-breakpoint,
$end-breakpoint,
$behavior: "fixed-start-value",
$unit: "px"
) {
// ...
}.element {
font-size: responsive-value(2, 1, 48, 23.4375, "fixed-both", "rem");
padding: responsive-value(20, 10, 768, 375, "fixed-end-value", "px");
margin-bottom: responsive-value(30, 15, 1440, 280);
}$start-value(number): The initial value of the property. Only accepts numeric values without units. Must not be equal to$end-value.$end-value(number): The final value of the property. Only accepts numeric values without units. Must not be equal to$start-value.$start-breakpoint(number): The initial breakpoint. At this breakpoint, the property value will be equal to$start-value. Only accepts positive numeric values without units. Must not be less than or equal to$end-breakpoint.$end-breakpoint(number): The final breakpoint. At this breakpoint, the property value will be equal to$end-value. Only accepts positive numeric values or0(zero) without units. Must not be greater than or equal to$start-breakpoint.$behavior(string, optional): Accepts 4 values:"not-fixed": The$start-valueand$end-valueproperties are not fixed before and after breakpoints."fixed-both": The$start-valueand$end-valueproperties are strictly fixed before and after breakpoints."fixed-start-value": At this value,$start-valueis strictly fixed before$start-breakpoint. Default value."fixed-end-value": At this value,$end-valueis strictly fixed after$end-breakpoint.
$unit(string, optional): CSS unit for numeric values. Default is"px". When changing the unit,$start-value,$end-value,$start-breakpoint, and$end-breakpointshould be written in the format of the specified unit.
- One of the CSS mathematical functions:
min(),max(),clamp().
- If
$start-value,$end-value,$start-breakpoint, or$end-breakpointare not numeric or have units. - If
$start-valueand$end-valueare equal. - If
$start-breakpointis less than or equal to zero. - If
$end-breakpointis a negative number. - If
$start-breakpointis less than$end-breakpoint. - If
$start-breakpointis equal to$end-breakpoint. - If the value of
$behavioris incorrect.