Aligning Footer Button to right in Lightning card

buttonlightning-cardlightning-web-componentsslds

I am working on dashboard screen. I have a lightning card which where I want a button on right side inside a footer.
Below is the code I am using.

But When I am trying to align the button inside footer to right using either slds-float_right or even CSS, it is breaking and going outside of card.

           <lightning-card>
                <div slot="title" class="cardHeading">New</div>
                <div class="slds-border_top"></div>
                    <div class="slds-text-align_center">
                        <span class="countText">
                            100
                        </span>       
                    </div>
                    <div class="slds-align_absolute-center">
                            Based on current Fiscal Month
                    </div>
                    <div slot="footer"> 
                            <button  title="View"  data-id='test' onclick={handlenavigation}  class="slds-card__footer-action viewButton slds-button slds-button_neutral">View</button>           
                    </div>
            </lightning-card>

enter image description here

Can we achieve this anyhow?

Best Answer

<template>

<lightning-card>
    <div slot="title" class="cardHeading">New</div>
    <div class="slds-border_top"></div>
        <div class="slds-text-align_center">
            <span class="countText">
                100
            </span>       
        </div>
        <div class="slds-align_absolute-center">
                Based on current Fiscal Month
        </div>
        <div slot="footer" class="slds-clearfix"> 
            <lightning-button label="Neutral" title="Non-primary action"   class="slds-var-m-left_x-small slds-float_right"></lightning-button>
      
        </div>
</lightning-card>
Related Topic