Answer the question
In order to leave comments, you need to log in
Webpack optimization of styles, classes?
At the entrance there are such classes
.class_1 {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.class_2 {
position: absolute;
top: 0;
bottom: 0;
}
.class_1, .class_2 {
position: absolute;
top: 0;
bottom: 0;
}
.class_1 {
right: 0;
left: 0;
}
Answer the question
In order to leave comments, you need to log in
postcss-merge-selectors - I didn't delve into the essence of this plugin, but it seems to me that it works if your selectors are different, and the styles inside are the same, then it merges them.
in your case it is better to use extend
.class_1 {
@extend .class_2;
right: 0;
left: 0;
}
.class_2 {
position: absolute;
top: 0;
bottom: 0;
}
%position {
position: absolute;
top: 0;
bottom: 0;
}
.class_1 {
@extend %position;
right: 0;
left: 0;
}
.class_2 {
@extend %position;
}
Because the display rule for your component is set by the css selector , not the key of its own style property .
This is how it will work:
var leftMenu = document.querySelector(".left-menu");
var displayValue = window.getComputedStyle(leftMenu,null).getPropertyValue("display");
console.log(displayValue === 'none');
leftMenu.style.display are inline styles. If you set styles via CSS, they will not appear in the style property of the element. They need to be read differently.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question