Skip to content

fluid and width usage #180

@keul

Description

@keul

Probably generally related to #172

When using the fluid prop with a grid scoped inside a small container I start seeing horizontal scroll.

This because the CSS rules is like the following:

@media only screen and (min-width: 64em)
.fUrYXC {
    width: 61rem;
}

See https://github.com/LoicMahieu/react-styled-flexboxgrid/blob/7f2961b23455466b9888b77f2894223d8fd084ed/src/components/Grid.js#L13:L20

I think that this behavior should copy what other CSS frameworks like Bootstrap are doing for non-fluid layout, so using max-width:

.container, .container-sm {
    max-width: 540px;
}

Workaround

While waiting for a fix I'm using a fixed version of Grid component:

import { Grid as BaseGrid } from 'react-styled-flexboxgrid';
import gridConfig, { DIMENSION_NAMES } from 'react-styled-flexboxgrid/src/config';

const Grid = styled(BaseGrid)`
  ${p => !p.fluid && css`
    ${DIMENSION_NAMES.map(t =>
    gridConfig(p).container[t] && gridConfig(p).media[t]`
        width: 100%;
        max-width: ${p => gridConfig(p).container[t]}rem;
      `
  )}
  `}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions