Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

float right button without going outside parent div tailwindcss

I am trying to float a button to the right of a card. I want it to appear in the bottom righthand corner.

When I use a float right. It appears outside the parent div, is there a way to position it correctly?

<div class="m-10">
    <div>
        <div class="bg-white shadow-lg border-grey w-1/3 ">
            <div class="p-4 flex">
                <div class="pt-3 text-center font-bold text-2xl w-16  h-16 bg-grey-lightest">
                    D
                </div>
                <div class="ml-4">
                    Team Name
                </div>
            </div>
            <div class="float-right">
                <a :href="'/company/' + team.id">
                    <button class="ml-2 bg-blue hover:bg-blue-dark text-white text-sm font-bold rounded p-2">
                        View
                    </button>
                </a>
            </div>
        </div>
    </div>
</div>

enter image description here

I have a running sandbox here with the code

https://codesandbox.io/s/tailwind-css-nl0ph

like image 285
JaChNo Avatar asked Jul 19 '26 23:07

JaChNo


1 Answers

Instead of using the float-right class use text-right

like image 129
Rich Avatar answered Jul 21 '26 15:07

Rich