In tailwind.css, .rounded-lg has no effect on tables.
P粉447495069
P粉447495069 2023-07-24 20:47:03
0
1
581
<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粉447495069
P粉447495069

reply all(1)
P粉478445671

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,您应该可以保持圆角的同时保留角边框。 
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template