Skip to content

Instantly share code, notes, and snippets.

@Sergioamjr
Last active December 9, 2018 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sergioamjr/5941b849ade77b673bbf1b1be3bd0a03 to your computer and use it in GitHub Desktop.
Save Sergioamjr/5941b849ade77b673bbf1b1be3bd0a03 to your computer and use it in GitHub Desktop.
Sistema de Grid com Styled-components
import styled from 'styled-components'
export const Container = styled.div`
margin: 0 auto;
padding: 0 15px;
max-width: 1200px;
`;
export const Grid = styled.div`
display: flex;
flex-wrap: wrap;
margin: 0 -15px;
`;
export const Column = styled.div`
box-sizing: border-box;
padding: 0 15px;
width: ${({xs}) => (xs ? `${xs / 12 * 100}%` : "100%")};
@media screen and (min-width: 768px) {
width: ${({sm, xs}) => (
sm ? `${sm / 12 * 100}%` :
xs ? `${xs / 12 * 100}%` :
"100%"
)};
}
@media screen and (min-width: 992px) {
width: ${({md, sm, xs}) => (
md ? `${md / 12 * 100}%` :
sm ? `${sm / 12 * 100}%` :
xs ? `${xs / 12 * 100}%` :
"100%"
)};
}
@media screen and (min-width: 1200px) {
width: ${({lg, md, sm, xs}) => (
lg ? `${lg / 12 * 100}%` :
md ? `${md / 12 * 100}%` :
sm ? `${sm / 12 * 100}%` :
xs ? `${xs / 12 * 100}%` :
"100%"
)};
}
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment