Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Card Layout is Broken at Mobile View Port - With CSS Grid

Hi Folks

I am Working on Implementing Card Layout , such That when user is on Mobile Experience the cards Should Stack Horizontally and the user should be able to scroll through the Cards via Carousel Style (I am using tinyslider as 3rd party JS Linbrary for this)

CodePen Link: https://codepen.io/sqaureone/pen/mdPdYNy

Problem: Though i could stack the Cards Horizontally on the Mobile ViewPort, and also i could get the Carousel , The Layout of the Cards are Completely broken.

Any Inputs on this will help me.

Thank you Challa Ravi

1 Answer

Brad Chandler
Brad Chandler
15,301 Points

Looking at your codepen example, it looks like the 3rd party slider you are using is applying the following rule:

#base > .tns-item {
    width: calc(14.2857%);
}

I would recommend looking into the documentation for setting up the width for your grid items.
Alternatively you could set the style to take up 100% of available space. Also, this might be an issue of mixing grid with the slider. Whenever, the sliders I have worked with move items in space by using css translate and absolute positioning. Grid may not work the best for these.

Thank you For the Pointer Brad. One thing even i am realizing is that Grid might not be a better option while using Slider.