I have the following problem with my design. It happens that depending on the size of the screen the design must be adapted, but when it is ‘xl’ it is displayed badly. The menu uses space on the screen and the contact div is below it, this should be on the right side of the menu respecting the size of both. How can I make it work well? (I leave you an image and my code)
<div id="main_menu" class="fixed top-0 left-0 h-screen w-32 m-0 flex flex-col bg-gray-900 text-white invisible xl:visible 2xl:visible">
<div class="text-7xl relative flex items-center justify-center text-center mt-2">
C
</div>
<div class="mt-4 relative flex items-center justify-center text-center">
<p>TESTING</p>
</div>
<div class="mt-40">
<div class="sidebad">
<i><p>TESTING 1</p></i>
</div>
<div class="sidebad">
<i><p>TESTING 2</p></i>
</div>
<div class="sidebad">
<i><p>TESTING 3</p></i>
</div>
<div class="sidebad">
<i><p>TESTING 4</p></i>
</div>
<div class="sidebad">
<i><p>TESTING 5</p></i>
</div>
</div>
</div>
<div id="main_body" class="container mx-auto">
<div class="grid grid-cols-2 mt-40">
<div class="border border-indigo-600">
<div class="text-white lg:text-7xl font-Martel font-extrabold p-10">
<p>HELLO,</p>
<p>THIS IS,</p>
<p>A WEB </p>
</div>
<div class="mt-20 p-10">
<button class="btn-contact">CONTACT !</button>
</div>
</div>
</div>
<div class="py-96">
<div class="p-10">
<p class="text-blue-500 text-7xl font-Martel font-extrabold">ABOUT</p>
<br>
<div class="bg-[url('../public/images/work_2.png')]">
</div>
<p class="text-black">It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
</div>
<div class="p-10 grid grid-cols-1 sm:grid-cols-1 md:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-5">
<!--Card 1-->
<div class="rounded overflow-hidden shadow-lg bg-white">
<img class="w-full" src="/mountain.jpg" alt="Mountain">
<div class="px-6 py-4">
<div class="font-bold text-xl mb-2">Mountain</div>
<p class="text-gray-700 text-base">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatibus quia, nulla! Maiores et perferendis eaque, exercitationem praesentium nihil.
</p>
</div>
<div class="px-6 pt-4 pb-2">
<span class="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">#photography</span>
<span class="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">#travel</span>
<span class="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">#winter</span>
</div>
</div>
<!--Card 2-->
<div class="rounded overflow-hidden shadow-lg bg-white">
<img class="w-full" src="/river.jpg" alt="River">
<div class="px-6 py-4">
<div class="font-bold text-xl mb-2">River</div>
<p class="text-gray-700 text-base">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatibus quia, nulla! Maiores et perferendis eaque, exercitationem praesentium nihil.
</p>
</div>
<div class="px-6 pt-4 pb-2">
<span class="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">#photography</span>
<span class="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">#travel</span>
<span class="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">#summer</span>
</div>
</div>
<!--Card 3-->
<div class="rounded overflow-hidden shadow-lg bg-white">
<img class="w-full" src="/forest.jpg" alt="Forest">
<div class="px-6 py-4">
<div class="font-bold text-xl mb-2">Forest</div>
<p class="text-gray-700 text-base">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatibus quia, nulla! Maiores et perferendis eaque, exercitationem praesentium nihil.
</p>
</div>
<div class="px-6 pt-4 pb-2">
<span class="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">#photography</span>
<span class="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">#travel</span>
<span class="inline-block bg-gray-200 rounded-full px-3 py-1 text-sm font-semibold text-gray-700 mr-2 mb-2">#fall</span>
</div>
</div>
</div>
</div>
</div>
live example
https://play.tailwindcss.com/hmcnBknbD7
>Solution :
There are two solutions that I have to suggest:
- Apply
xl:lm-32(left margin) to yourmain_bodythat is applied only for bigger screens (1280px). This way, you’ll have the gap you desire only on bigger screens.
- Create a container wrapping both the nav-bar and the content. Apply
flexon the container and remove thefixedposition of your nav-bar.
Your menu is hiding the main-contact because your menu’s position type is fixed. Fixed elements don’t leave a gap in the page where they would normally have been located.
