question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How To achive responsive behaviour of Grid List

See original GitHub issue

Bug, feature request, or proposal:

Shall have responsive directives as we have in angular-material(1) as given below

<md-grid-list
        md-cols-gt-md="12" md-cols="3" md-cols-md="8"
        md-row-height-gt-md="1:1" md-row-height="4:3"
        md-gutter-gt-md="16px" md-gutter-md="8px" md-gutter="4px">

What is the expected behavior?

Shall have a way to reduce or increase number of columns depending on screen size

What is the current behavior?

Not finding way to change number columns depending on screen size

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

13reactions
CDDeltacommented, Apr 23, 2017

You can workaround this by manually setting the number of grid columns in your own code. You can do it easily via flex-layout like this:

@ViewChild('grid')
private grid: MdGridList;`

constructor(private media: ObservableMedia) { }

ngAfterViewInit() {
        // ObservableMedia does not fire on init so you have to manually update the grid first.
        this.updateGrid();
	this.media.subscribe(change => { this.updateGrid(); });
}

updateGrid(): void {
	if (this.media.isActive('xl')) { this.grid.cols = 5; }
	else if (this.media.isActive('lg')) { this.grid.cols = 4; }
	else if (this.media.isActive('md')) { this.grid.cols = 3; }
	else if (this.media.isActive('sm')) { this.grid.cols = 2; }
	else if (this.media.isActive('xs')) { this.grid.cols = 1; }
}
1reaction
fsomme2scommented, Jul 31, 2017

md-cols-gt-md="12" md-cols="3" md-cols-md="8"... looks much better to me, the “solution” is more like a nasty workaround

Don’t get me wrong - it’s great that the solution by CDDelta works - it just seems too complicated compared to other responsive approaches. Having those attributes would be much easier to handle.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Responsive Grid Design: Ultimate Guide | by Nitish Khagwal
Responsive grid helps to maintain consistency and make faster design decisions. Kickstart your responsive grid design process with this ...
Read more >
Creating Responsive Design With Grids - Aela School
Basic guidelines to work with Grids · 1) Place elements inside column sets · 2) Do not use columns as paddings · 3)...
Read more >
Look Ma, No Media Queries! Responsive Layouts Using CSS ...
The first line ( display: grid; ) is changing the behavior of the .hero element to be a grid container. · The second...
Read more >
How to build a responsive grid system | Zell Liew
Step 1: Choose a spec · Step 2: Set box-sizing to border box · Step 3: Create the grid container · Step 4:...
Read more >
How to Make a Responsive Grid With Only Three Lines of CSS
For example, imagine you have to display a list of products for a commerce app. Your task is to make it responsive, so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found