Grid Column Start / End

    v1.2.0+

    Utilities for controlling how elements are sized and placed across grid columns.

    Use the utilities to make an element span n columns.

    Use the col-start-{n} and col-end-{n} utilities to make an element start or end at the nth grid line. These can also be combined with the col-span-{n} utilities to span a specific number of columns.

    Note that CSS grid lines start at 1, not 0, so a full-width element in a 6-column grid would start at line 1 and end at line 7.

    Grid Column Start / End - 图2

    1. <div class="grid grid-cols-6 gap-4">
    2. <div class="col-start-2 col-span-4 ..."></div>
    3. <div class="col-start-1 col-end-3 ..."></div>
    4. <div class="col-end-7 col-span-2 ..."></div>
    5. <div class="col-start-1 col-end-7 ..."></div>
    6. </div>

    To control the column placement of an element at a specific breakpoint, add a {screen}: prefix to any existing grid-column utility. For example, use md:col-span-6 to apply the col-span-6 utility at only medium screen sizes and above.

    For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.

    all

    sm

    Grid Column Start / End - 图5

    md

    lg

    Grid Column Start / End - 图7

    xl

    For creating more col-{value} utilities that control the grid-column shorthand property directly, customize the gridColumn section of your Tailwind theme config:

    1. // tailwind.config.js
    2. theme: {
    3. extend: {
    4. + 'span-16': 'span 16 / span 16',
    5. }
    6. }
    7. }
    8. }

    We use this internally for our col-span-{n} utilities. Note that since this configures the grid-column shorthand property directly, we include the word span directly in the value name, it’s not baked into the class name automatically. That means you are free to add entries that do whatever you want here — they don’t just have to be span utilities.

    To add new col-start-{n} utilities, use the gridColumnStart section of your Tailwind theme config:

    To add new col-end-{n} utilities, use the gridColumnEnd section of your Tailwind theme config:

    1. // tailwind.config.js
    2. module.exports = {
    3. theme: {
    4. extend: {
    5. gridColumnEnd: {
    6. + '13': '13',
    7. + '15': '15',
    8. + '16': '16',
    9. }
    10. }
    11. }
    12. }

    Learn more about customizing the default theme in the .

    By default, only responsive variants are generated for grid-column utilities.

    You can control which variants are generated for the grid-column utilities by modifying the gridColumn, gridColumnStart, and gridColumnEnd properties in the variants section of your tailwind.config.js file.

    Learn more about configuring variants in the configuring variants documentation.

    Disabling

    If you don’t plan to use the grid-column utilities in your project, you can disable them entirely by setting the gridColumn, gridColumnStart and gridColumnEnd properties to false in the corePlugins section of your config file:

    1. // tailwind.config.js
    2. module.exports = {
    3. corePlugins: {
    4. // ...
    5. + gridColumn: false,
    6. + gridColumnStart: false,
    7. + gridColumnEnd: false,