Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place button on right side in reactjs

I am creating a simple UI for a webapp using React and Ant Design. I would like to place a Button at the top right of the screen. My component render function looks something like this:

return (
    <div style={{something here?}}>
        <div style={{something else here?}}>
            <Button>Logout</Button>
        </div>
        <div>
           {Main components here}
        </div>
    </div>
);

I have tried adding various things to the outer and/or inner dics and have not been able to move the button to the right - it always stays on the left. How do I make it move to the right?

like image 683
Marc Avatar asked Jan 27 '23 02:01

Marc


1 Answers

return (
    <div style={{}}>
        <div style={{float: 'right'}}>
            <Button>Logout</Button>
        </div>
       <div style={{clear: 'both'}}></div>
        <div>
           {Main components here}
        </div>
    </div>
);

Try that, also, this is not a React question, it should be tagged CSS

like image 82
mikeb Avatar answered Jan 28 '23 15:01

mikeb