I want to use a Polymorphism mixin in Less, I have set default values for my parameters,
regarding that both the Polymorphism mixins have different number of parameters, when using the mixin for different elements, I wonder if I can only assign one specific parameter value and let the others keep their default values.
For instance, here I have two Ploymorphism mixins ,.testMixin
., and .box_1
and .box_2
using them respectively, having not given arguments for .box_1
's mixin, the compiled CSS includes both mixins with the given default values. But I have assigned the only argument 10 to the mixin of .box_2
, and it has set the first parameter of both mixins to 10, and kept the other parameters values', if available.
Here are the questions:
First, What should I do in order to assign the second parameter of the second mixin to a value, keeping both the first and third parameters to their default values?
Second, How can I only use one of the polymorphism mixins? regarding that polymorphism mixins are used with respect to the number of arguments they are given.
.testMix(@f-size:2){
font-size: (@f-size * 10px);
}
.testMix(@h:300, @s:70%, @l:50%){
color: hsl(@h, @s, @l);
}
.box{
&_1{
.testMix();
}
&_2{
.testMix(10);
// How to assign only one argument, e.g. only the second argument of first mixin
}
}
If I've understood correctly, what is required is for the image to become scaled but remain within its div - not to ooze out over the padding.
If you use a margin on the container rather than padding on the image then the img zooms slightly, but stays within its element.
Note: you might like to consider object-fit: contain or cover on the image rather than width/height 100% so it doesn't become distorted, but depends on your use case of course.