Site logo

Archived topic

Turn off Sider left-menu from homepage?

15 replies · Started by Oier on November 30, 2021

Viewing posts 1–15 of 16

I'm currently working on the homepage for a website. I just need a grid with cards that will link to pages (not posts). Just three cards for now, but it will have more later.
This is the page: https://proba.pilpilean.eus/sbsi/
The grid I am working on is the top one, trying to get something similar to the bottom one. Before working on its style I'd like to solve one thing with the responsive side of the grid.
I like how the cards look in the bottom example in their original size, I wouldn't care if they were more square-like. But then, the cards get too narrow when you make the screen less wide. The tablet-view (which reduces the columns from 3 to 2) makes it look better, but it triggers too late, making the cards look too vertical.
However, if I turn off the CSS styling that makes the menu stay fixed on the left side (I copied the code of the Sider example in the theme documentation) I kind of solve that problem, as then there is enough space for the cards to not get too narrow before the tablet-view triggers. In addition, the homepage is the only page in which I don't need the menu there. I could use the normal vertical menu with 2-3 menu items.
I guess I would need to do that changing the CSS styling of the Sider menu right? How can I turn off that code for the homepage?

Does that make sense or am I overcomplicating it? Maybe there is a simpler way (different template for the homepage only?) to make the cards look better or the tablet-view trigger sooner without touching that menu code. Tablet-view triggering sooner may not be a good idea though? Adding some CSS with max-height could help, making the cards look not so vertical, but the columns would be too narrow anyway.

I am actually using that. The GB grid is inside the WP column block (just 1 column) . I did that just because I wanted the grid to take 100% of the width of the content space. Didn't manage to do so otherwise, there probably is a better way to do so.
I can take the grid out of the column block, I actually created the grid outside, and then pasted it in. But I had the same problem when the grid was outside anyway and could not find a way to solve it.

Doesn't that just give the containers a fixed width?
I want them to change the width depending on the browser's width. Can I somehow make the grid change from 3 to 2 (and from 2 to 1) columns at a width of my choice? That would solve the problem. I would need it to change at a higher width than it does now.

Hi there,

the flex basis sets the 'ideal' width - but doesn't fix it.
If you made the settings for each column in desktop:

grow: 1
shrink: 0
basis: 350px

Then you will get 3 columns when there is enough room for 3 x 350px ( plus any gap ) - and when there isnt the grid will create new rows and force the grid columns to fill the space.

True, I was missing the grow/shrink part. Anyway, this doesn't work either as I get 2 cards in one row with 50% width each, and 1 card in the new row with 100% width.
I'd like all the cards to have the same size always.

this doesn’t work either as I get 2 cards in one row with 50% width each, and 1 card in the new row with 100% width.

Try set instead:

grow:0
shrink:1
basis: 350px

That's what I first tried, cards have a fixed 350px width for almost any screen size. Even when there are just 2 cards in a row and plenty of white space to fill they just have the fixed 350px width. Then when there is no place for 2 cards in the row one just jumps to the next row.
Also, when there is just 1 card in each row they have just 350px width even if they fill less than 60% of the whole row.

All right, then can you switch back to the initial settings with 33% width?

We would try to figure out a CSS solution to change the desktop/tablet breaking point then.

Done.
Perfect, thanks!
About that solution for the breaking point, would that affect only the grid, or the whole page (menus...)?

We can't change the site's breaking point, there's a lot of CSS already built in the theme, we can't override all of them.

What we can do is to try targeting this specific Grid :)

Let's add a custom CSS class to the Grid block, eg. custom_grid_breakpoint, then add this CSS:
How to add class to blocks: https://wordpress.com/support/adding-additional-css-classes-to-blocks/

@media (max-width: 1200px) and (min-width:768px) {
.gb-grid-wrapper.custom_grid_breakpoint > .gb-grid-column {
    width: 50%;
}
}

You can change the 1200px to the screen width that you want it to be 2 columns.

Let me know :)

Thanks Ying! That worked perfect!
Now I have another doubt about the primary navigation menu in the left.
The menu items are aligned in the center, but I'd like them to be aligned in the left, so that it looks like the menu widget below.
I tried many things but nothing worked for now.

You are welcome :) Try add this CSS:

@media (min-width: 950px) {
.site-header .main-navigation .main-nav > ul {
    align-items: flex-start;
}
.site-header .main-navigation .main-nav > ul > li > a {
    padding: 0;
}
}

And change this CSS:

.nav-float-right #site-navigation {
    margin-right: auto;
}

https://www.screencast.com/t/KLwg0BZjwZdl

To:

.nav-float-right #site-navigation {
    margin-right: auto;
    margin-left: 0;
}

Let me know :)

Solved! Thanks again.

This archived topic is closed to new replies.