Css grid layout with empty column
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am new to css grid and I would like to know if it's possible to use it in the following scenario. I would like to create a layout containing 3 columns, and each column containing a button. In some cases, the button from the last column will not displayed (using angular ngif), but I don't want the layout to be changed (even if the last column does not contain anything, it should look the as if it was). How this be achieved?
I've tried creating 3 columns by using grid-template-columns: 1fr repeat(3, auto);
but if the button in the last column is not displayed, all the other buttons are shifted a little to the right.
css

add a comment |
I am new to css grid and I would like to know if it's possible to use it in the following scenario. I would like to create a layout containing 3 columns, and each column containing a button. In some cases, the button from the last column will not displayed (using angular ngif), but I don't want the layout to be changed (even if the last column does not contain anything, it should look the as if it was). How this be achieved?
I've tried creating 3 columns by using grid-template-columns: 1fr repeat(3, auto);
but if the button in the last column is not displayed, all the other buttons are shifted a little to the right.
css

4
what have you tried? post your complete code here
– John Velasquez
Jan 3 at 8:35
add a comment |
I am new to css grid and I would like to know if it's possible to use it in the following scenario. I would like to create a layout containing 3 columns, and each column containing a button. In some cases, the button from the last column will not displayed (using angular ngif), but I don't want the layout to be changed (even if the last column does not contain anything, it should look the as if it was). How this be achieved?
I've tried creating 3 columns by using grid-template-columns: 1fr repeat(3, auto);
but if the button in the last column is not displayed, all the other buttons are shifted a little to the right.
css

I am new to css grid and I would like to know if it's possible to use it in the following scenario. I would like to create a layout containing 3 columns, and each column containing a button. In some cases, the button from the last column will not displayed (using angular ngif), but I don't want the layout to be changed (even if the last column does not contain anything, it should look the as if it was). How this be achieved?
I've tried creating 3 columns by using grid-template-columns: 1fr repeat(3, auto);
but if the button in the last column is not displayed, all the other buttons are shifted a little to the right.
css

css

edited Jan 3 at 14:12
Michael_B
158k50255363
158k50255363
asked Jan 3 at 8:30
RocshyRocshy
1,42693148
1,42693148
4
what have you tried? post your complete code here
– John Velasquez
Jan 3 at 8:35
add a comment |
4
what have you tried? post your complete code here
– John Velasquez
Jan 3 at 8:35
4
4
what have you tried? post your complete code here
– John Velasquez
Jan 3 at 8:35
what have you tried? post your complete code here
– John Velasquez
Jan 3 at 8:35
add a comment |
1 Answer
1
active
oldest
votes
Because the grid template is applied to the direct children so if you have 3 columns you should have 3 direct children.
If you have a ng-if you will have only 2 children when the ng-if evaluates to false therefore I would recommend you to encapsulate this ng-if into another div so that you always have this 3 children even if the last one is empty.
for example:
<div class="my-grid">
<div>column 1</div>
<div>column 2</div>
<div>
<div ng-if="displayColumn3">column 3</div>
</div>
</div>
hope this makes sense and helps.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2fstackoverflow.com%2fquestions%2f54018718%2fcss-grid-layout-with-empty-column%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Because the grid template is applied to the direct children so if you have 3 columns you should have 3 direct children.
If you have a ng-if you will have only 2 children when the ng-if evaluates to false therefore I would recommend you to encapsulate this ng-if into another div so that you always have this 3 children even if the last one is empty.
for example:
<div class="my-grid">
<div>column 1</div>
<div>column 2</div>
<div>
<div ng-if="displayColumn3">column 3</div>
</div>
</div>
hope this makes sense and helps.
add a comment |
Because the grid template is applied to the direct children so if you have 3 columns you should have 3 direct children.
If you have a ng-if you will have only 2 children when the ng-if evaluates to false therefore I would recommend you to encapsulate this ng-if into another div so that you always have this 3 children even if the last one is empty.
for example:
<div class="my-grid">
<div>column 1</div>
<div>column 2</div>
<div>
<div ng-if="displayColumn3">column 3</div>
</div>
</div>
hope this makes sense and helps.
add a comment |
Because the grid template is applied to the direct children so if you have 3 columns you should have 3 direct children.
If you have a ng-if you will have only 2 children when the ng-if evaluates to false therefore I would recommend you to encapsulate this ng-if into another div so that you always have this 3 children even if the last one is empty.
for example:
<div class="my-grid">
<div>column 1</div>
<div>column 2</div>
<div>
<div ng-if="displayColumn3">column 3</div>
</div>
</div>
hope this makes sense and helps.
Because the grid template is applied to the direct children so if you have 3 columns you should have 3 direct children.
If you have a ng-if you will have only 2 children when the ng-if evaluates to false therefore I would recommend you to encapsulate this ng-if into another div so that you always have this 3 children even if the last one is empty.
for example:
<div class="my-grid">
<div>column 1</div>
<div>column 2</div>
<div>
<div ng-if="displayColumn3">column 3</div>
</div>
</div>
hope this makes sense and helps.
answered Jan 3 at 9:52
Didier CorronelDidier Corronel
6018
6018
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f54018718%2fcss-grid-layout-with-empty-column%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
4
what have you tried? post your complete code here
– John Velasquez
Jan 3 at 8:35