Why does Magento LESS compiling re-order my code
I have been trying to create a basic grid for my theme. Here's the code
.row {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -20px;
margin-left: -20px;
&,
> .col {
box-sizing: border-box;
}
&.align-items-center {
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
> .col {
position: relative;
width: 100%;
min-height: 1px;
padding-right: 20px;
padding-left: 20px;
}
> .col-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__s) {
.row {
> .col-s-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-s-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-s-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-s-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-s-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
.row {
> .col-m-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-m-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-m-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-m-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-m-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__l) {
.row {
> .col-l-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-l-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-l-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-l-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-l-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
}
But if I try to add the classes col col-half col-m-quater
to an element in the grid it does not work as intended.
So I looked into the CSS and when the code is compiled the breakpoints are being added before the normal classes. So the class col-half
is much further down the file than the class col-m-half
so that is always getting over-ridden by the col-half class.
My question is, why is my breakpoint code being placed above the class not in breakpoints.
And how much benefit is there to using Magento's .media-width()
over the standard @media
query
magento2 frontend styles less-compilation
add a comment |
I have been trying to create a basic grid for my theme. Here's the code
.row {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -20px;
margin-left: -20px;
&,
> .col {
box-sizing: border-box;
}
&.align-items-center {
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
> .col {
position: relative;
width: 100%;
min-height: 1px;
padding-right: 20px;
padding-left: 20px;
}
> .col-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__s) {
.row {
> .col-s-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-s-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-s-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-s-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-s-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
.row {
> .col-m-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-m-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-m-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-m-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-m-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__l) {
.row {
> .col-l-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-l-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-l-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-l-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-l-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
}
But if I try to add the classes col col-half col-m-quater
to an element in the grid it does not work as intended.
So I looked into the CSS and when the code is compiled the breakpoints are being added before the normal classes. So the class col-half
is much further down the file than the class col-m-half
so that is always getting over-ridden by the col-half class.
My question is, why is my breakpoint code being placed above the class not in breakpoints.
And how much benefit is there to using Magento's .media-width()
over the standard @media
query
magento2 frontend styles less-compilation
add a comment |
I have been trying to create a basic grid for my theme. Here's the code
.row {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -20px;
margin-left: -20px;
&,
> .col {
box-sizing: border-box;
}
&.align-items-center {
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
> .col {
position: relative;
width: 100%;
min-height: 1px;
padding-right: 20px;
padding-left: 20px;
}
> .col-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__s) {
.row {
> .col-s-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-s-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-s-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-s-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-s-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
.row {
> .col-m-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-m-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-m-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-m-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-m-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__l) {
.row {
> .col-l-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-l-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-l-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-l-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-l-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
}
But if I try to add the classes col col-half col-m-quater
to an element in the grid it does not work as intended.
So I looked into the CSS and when the code is compiled the breakpoints are being added before the normal classes. So the class col-half
is much further down the file than the class col-m-half
so that is always getting over-ridden by the col-half class.
My question is, why is my breakpoint code being placed above the class not in breakpoints.
And how much benefit is there to using Magento's .media-width()
over the standard @media
query
magento2 frontend styles less-compilation
I have been trying to create a basic grid for my theme. Here's the code
.row {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -20px;
margin-left: -20px;
&,
> .col {
box-sizing: border-box;
}
&.align-items-center {
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
> .col {
position: relative;
width: 100%;
min-height: 1px;
padding-right: 20px;
padding-left: 20px;
}
> .col-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__s) {
.row {
> .col-s-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-s-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-s-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-s-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-s-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
.row {
> .col-m-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-m-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-m-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-m-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-m-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
}
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__l) {
.row {
> .col-l-full {
-webkit-box-flex: 0;
-ms-flex: 0 0 100%;
flex: 0 0 100%;
max-width: 100%;
}
> .col-l-half {
-webkit-box-flex: 0;
-ms-flex: 0 0 50%;
flex: 0 0 50%;
max-width: 50%;
}
> .col-l-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 33.333333%;
flex: 0 0 33.333333%;
max-width: 33.333333%;
}
> .col-l-two-third {
-webkit-box-flex: 0;
-ms-flex: 0 0 66.66666%;
flex: 0 0 66.66666%;
max-width: 66.66666%;
}
> .col-l-quater {
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 25%;
max-width: 25%;
}
}
}
But if I try to add the classes col col-half col-m-quater
to an element in the grid it does not work as intended.
So I looked into the CSS and when the code is compiled the breakpoints are being added before the normal classes. So the class col-half
is much further down the file than the class col-m-half
so that is always getting over-ridden by the col-half class.
My question is, why is my breakpoint code being placed above the class not in breakpoints.
And how much benefit is there to using Magento's .media-width()
over the standard @media
query
magento2 frontend styles less-compilation
magento2 frontend styles less-compilation
asked 5 mins ago
CallumCallum
1144
1144
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264589%2fwhy-does-magento-less-compiling-re-order-my-code%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f264589%2fwhy-does-magento-less-compiling-re-order-my-code%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown