Alex Cotton
Alex Cotton

Reputation: 101

Addidtional vertical space between two grid items

I´m using a grid layout of 2 columns for a device width greater than 768px, and for some reason it decides to increase the spacing between that element and the one positioned after at that breakpoint.

I need to fix the height issue, so that the height is defined by the content in that column.

** I am using Tailwind CSS and Next.js.

Image of the problem I have in the browser

import React from 'react'
    
function servicios() { 
  return ( 
    <div>
    
      {/* Carousel component */}
    
      <div className='grid grid-cols-1 md:grid-rows-6 md:grid-cols-2 sm:px-5'>
        
        <div className='flex flex-col px-5 my-10 md:row-start-1 md:col-start-1 md:col-span-1'>
          <h2 className='text-xl mb-4'>Inbound Marketing</h2>
          <p className='text-gray-400'>A través del Inbound Marketing establecemos... </p>
        </div>
        
        <div className='flex flex-col px-5 my-10 md:row-start-2 md:col-start-2'>
          <h2 className='text-xl mb-4'>¿Qué es el Inbound Marketing?</h2>
          <p className='text-gray-400'>El Inbound Marketing es...</p>
        </div>
      
        <div className='flex flex-col px-5 my-10 md:row-start-3 md:col-start-1'>
          <h2 className='text-xl mb-4'>Cómo funciona:</h2>
          <p className='text-gray-400'>La idea del Inbound Marketing es...</p>
          <p className='text-gray-400'>Tratamos de presentar...</p>
        </div>
      
        <div className='flex flex-col px-5 my-5 md:row-start-4 md:col-start-1'>
          <h2 className='text-xl mb-4'>¿Qué resultados queremos conseguir?</h2>
          <p className='text-gray-400'>El Inbound Marketing sirve...</p>
          <p className='text-gray-400'>Podemos...</p>
          <p className='text-white my-2'>Aumentar...</p>
          <p className='text-white my-2'>Disminuir...</p>
          <p className='text-white my-2'>Mejorar...</p>
        </div>
      
        <div className='px-5 my-5 md:row-start-5 md:col-start-1'>
          <video autoPlay loop muted>
            <source src="/social.mp4" type='video/mp4'/>
          </video>
        </div>
        <div className='flex flex-col px-5 my-10 md:row-start-5 md:col-start-2'>
          <h2 className='text-xl mb-4'>Ads Sociales</h2>
          <p className='text-gray-400'>Es un tipo de publicidad...</p>
        </div>
      
        <div className='flex flex-col px-5 my-10 md:row-start-6 md:col-start-1'>
          <h2 className='text-xl mb-4'>Campañas PPC</h2>
          <p className='text-gray-400'>También gestionamos...</p>
          <h2 className='text-xl my-4'>¿Cómo lo hacemos...</h2>
          <p className='text-gray-400'><span className='text-white'>Análisis:</span> Estudio...</p>
          <p className='text-gray-400 mt-2'><span className='text-white'>Análisis... </span>Estudio y...</p>
          <p className='text-gray-400 mt-2'><span className='text-white'>Propuestas...</span> Propuesta de acciones...</p>
          <p className='text-white mt-4'>Para poder desempeñar...</p>
        </div>
        <div className='px-5 md:row-start-6 md:col-start-2'>
          <video autoPlay loop muted>
            <source src="/analitics.mp4" type="video/mp4" />
          </video>
        </div>
      </div>

Upvotes: 0

Views: 616

Answers (1)

AnthonyDev220
AnthonyDev220

Reputation: 709

You have 8 sub div inside your grid div. Therefore, you should set your md:grid-rows-6 to md:grid-rows-8, otherwise, the spacing would behavior abnormally to maintain the right spacing for 6 div.

Check out this new demo I created: https://codesandbox.io/s/modest-darkness-9utcvm?file=/src/App.js

Upvotes: 1

Related Questions