简体   繁体   中英

How to horizontally invert the input type=“text” for Calculator?

Im doing a Simple Calculator using html, css and javascript. I want to display the numbers on the right side of the input element?

How can I do that?

Is a better input type to use for a calculator? Is a way to move the numbers to the right? Like a calculator?

Thank You !

I would recommend to use input type="number" so only numbers can be inserted. But you could also use input type="text" as it was intended to be.

You can achieve the displaying of the numbers on the right side with text-align:right; in CSS.

 #number1 { text-align: right; } 
 <input id="number1" type="number" /> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM