search

Home  >  Q&A  >  body text

In tailwind.css, .rounded-lg has no effect on tables.

<p>Currently, I am using tailwind version 3.3.3. </p><p>I cannot get the rounded corners effect for the table. I tried adding a wrapper container with class name "overflow-hidden rounded-lg". This solves the rounded corners problem, but the borders on each side also disappear. How can I solve this problem? </p><p>My code is: </p><p><br /></p> <pre class="brush:php;toolbar:false;"><table class="w-50 m-auto font-inter text-left border-collapse rounded-lg"> <thead> <tr class="bg-[#f2f4f7]"> <th class="p-3 text-gray-500 text-xs font-semibold leading-none border border-gray-200"><span class="inline-flex gap-1">Plan</ span></th> <th class="p-3 text-gray-500 text-xs font-semibold leading-none border border-gray-200"><span class="inline-flex gap-1">No. of Subscription</span></th> </tr> </thead> <body> <tr> <td class="border border-gray-200 p-3">Silver plan USD Monthly</td> <td class="border border-gray-200 p-3">2</td> </tr> </tbody> </table></pre> <p><br /></p>
P粉447495069P粉447495069490 days ago540

reply all(1)I'll reply

  • P粉478445671

    P粉4784456712023-07-25 14:53:20

    To solve this problem, you can add an extra wrapping div around the table and apply the overflow-hidden rounded-lg class to that wrapping div, not the table itself

    <div class="w-50 m-auto">
        <div class="overflow-hidden rounded-lg">
            <table class="w-full font-inter text-left border-collapse">
                <thead>
                    <tr class="bg-[#f2f4f7]">
                        <th class="p-3 text-gray-500 text-xs font-semibold leading-none border border-gray-200"><span class="inline-flex gap-1">Plan</span></th>
                        <th class="p-3 text-gray-500 text-xs font-semibold leading-none border border-gray-200"><span class="inline-flex gap-1">No. of Subscription</span></th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td class="border border-gray-200 p-3">Silver plan USD Monthly</td>
                        <td class="border border-gray-200 p-3">2</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>```
    通过将表格包裹在一个div中,并将overflow-hidden rounded-lg类应用于该div,您应该可以保持圆角的同时保留角边框。 

    reply
    0
  • Cancelreply