<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Arpita Roy</title>
    <description>The latest articles on Forem by Arpita Roy (@devarpita).</description>
    <link>https://forem.com/devarpita</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1144639%2Fc5ff0a3c-0d23-4178-a2ed-514211275e26.png</url>
      <title>Forem: Arpita Roy</title>
      <link>https://forem.com/devarpita</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/devarpita"/>
    <language>en</language>
    <item>
      <title>Centering a Div with Tailwind CSS</title>
      <dc:creator>Arpita Roy</dc:creator>
      <pubDate>Thu, 02 Nov 2023 14:38:02 +0000</pubDate>
      <link>https://forem.com/devarpita/centering-a-div-with-tailwind-css-2fad</link>
      <guid>https://forem.com/devarpita/centering-a-div-with-tailwind-css-2fad</guid>
      <description>&lt;p&gt;To center a div both horizontally and vertically, you can use both Flexbox or grid. First, we must assign a height to the div, as a div's default height is zero.&lt;/p&gt;

&lt;p&gt;Here's an example with grid:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"grid place-items-center bg-gray-400 h-screen "&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
        Hello world!
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, &lt;code&gt;grid&lt;/code&gt; makes the container a grid container. Use &lt;code&gt;place-items-center&lt;/code&gt; to place grid items on the center of their grid areas on both axes.&lt;code&gt;h-screen&lt;/code&gt; makes the height of the container 100% of the viewport height (100vh).&lt;/p&gt;

&lt;p&gt;Here's an example with flexbox:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"flex justify-center items-center h-screen"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
    Your Content
  &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, &lt;code&gt;flex&lt;/code&gt; makes the container a flex container. &lt;code&gt;justify-center&lt;/code&gt; and &lt;code&gt;items-center&lt;/code&gt; center the child div along both the main axis and the cross axis. &lt;code&gt;h-screen&lt;/code&gt; makes the height of the container 100% of the viewport height (100vh).&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>html</category>
      <category>tailwindcss</category>
    </item>
  </channel>
</rss>
