Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to float a button element to the right and it isn't working as I would expect.

This is without "float:right;"

http://i.imgur.com/wSQxs.png[^]


And then it goes down to the next line when I add "float:right;".

http://i.imgur.com/QfEl2.png[^]


How would I make the button dock on the very right side of the gray box?
Posted

you can use this

XML
<div style="width: 50%;">
                    <div style="float: none;">
                        your text comes here
                    </div>
                    <div style="float: left;">
                        <input type="text" id="txtid" />
                    </div>
                    <div style="float: right;">
                        <input type="button" value="okay" />
                    </div>
                </div>
 
Share this answer
 
Comments
ZaiDz 25-May-12 22:15pm    
Thank you.
hitech_s 26-May-12 0:06am    
it's ok ZaiDz.
member60 26-May-12 0:54am    
My 5!
hitech_s 26-May-12 1:00am    
thanks member60
This works as expected when I run the sample page:
XML
<asp:Panel runat="server" ID="textPanel" BorderColor="Black" BorderWidth="2">
 <label>Dock float</label>
 <input style="float: right;" type="button" value="PressMe" />
</asp:Panel>

Though, I did find VS designer showing it on the next line as your image, but things were as per expectation when I run the app. Try out.
 
Share this answer
 
Comments
ZaiDz 25-May-12 0:55am    
Same thing happened.

http://i.imgur.com/tebgd.png
Sandeep Mewara 25-May-12 3:52am    
Not here. I see it all good.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900