Height

    Auto

    Use to let the browser determine the height for the element.

    Use h-screen to make an element span the entire height of the viewport.

    Height - 图2

    1. <div class="bg-gray-400 h-screen"></div>

    Fixed height

    Use h-{number} or h-px to set an element to a fixed height.

    1. <div class="h-8 w-8 ..."></div>
    2. <div class="h-12 w-12 ..."></div>

    Use h-full to set an element’s height to 100% of its parent, as long as the parent has a defined height.

    Height - 图4


    Responsive

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

    all

    Height - 图6

    sm

    md

    Height - 图8

    xl

    1. <div class="h-8 sm:h-12 md:h-16 lg:h-20 xl:h-24 w-32 bg-gray-400"></div>

    By default, Tailwind’s height scale is a combination of the default spacing scale as well as some additional values specific to heights.

    You can customize the spacing scale for padding, margin, width, and height all at once in the theme.spacing section of your tailwind.config.js file:

    1. // tailwind.config.js
    2. theme: {
    3. spacing: {
    4. + sm: '8px',
    5. + md: '16px',
    6. + lg: '24px',
    7. + xl: '48px',
    8. }
    9. }
    10. }

    To customize height separately, use the theme.height section of your tailwind.config.js file.

    By default, only responsive variants are generated for height utilities.

    You can control which variants are generated for the height utilities by modifying the height property in the variants section of your tailwind.config.js file.

    For example, this config will also generate hover and focus variants:

    1. // tailwind.config.js
    2. variants: {
    3. // ...
    4. - height: ['responsive'],
    5. + height: ['responsive', 'hover', 'focus'],
    6. }
    7. }
    1. // tailwind.config.js
    2. module.exports = {
    3. corePlugins: {
    4. // ...
    5. + height: false,
    6. }

    Min-Height →