Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.7K
Vistas
how to use calc() in tailwind CSS?

I have this html:

  <div class="container h-screen w-screen">
    <div class="navBar h-7"></div>
    <div class="content-container"></div>
  </div>

I have set the .navBar's height to h-7. Now I want to set .content-container's height to 100vh-(h-7).

How can i use calc() to set it?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

theme()

Use the theme() function to access your Tailwind config values using dot notation.

This can be a useful alternative to @apply when you want to reference a value from your theme configuration for only part of a declaration:

.content-container {
  height: calc(100vh - theme('spacing.7'));
}
over 4 years ago · Santiago Trujillo Denunciar

0

If you are using v2.x, add mode: 'jit' to your tailwind.config.js (no mode: 'jit' needed in tailwind v3)

module.exports = {
  mode: 'jit',
  ....
};

And use like this: (Without space!)

class="w-[calc(100%+2rem)]"

It will produce:

.w-\[calc\(100\%\+2rem\)\] {
  width: calc(100% + 2rem);
}

We can use the theme variables as well:

h-[calc(100%-theme(space.24))]

Tailwind v3 update

Now we can use an underscore _ instead of whitespaces:

Ref: Handling whitespace

<script src="https://cdn.tailwindcss.com"></script>
<div class="h-20 w-[calc(100%_-_10rem)] bg-yellow-200"></div>

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda