Question:
What is a simple way to align form fields?
?
2011-04-19 14:20:53 UTC
I am creating several pages for a mobile web site. The pages are simple check lists, using radio buttons for ok/not ok. I am using label tags and input tags, and I need to vertically align the radio buttons, without using table tags.

I also have a login page with login name: [input field] and password: [input field]. I want the 2 input fields to be vertically aligned as well.

Thank you in advance for your help.
Three answers:
2011-04-19 16:00:30 UTC
"CSS is too variable" is a big laugh!!! You use CSS exactly to make your web page look the way you want. With some effort, you can make it cross-browser compatible.



Writing code for what you want is an exercise in futility here if you want it done correctly so it does validate. A lot depends on the document type you want to code to. Sloppy syntax will mess you up.



If you had some code you started, it would be a great help to whip what you want done into shape.



Ron
circusmort
2011-04-19 21:53:08 UTC
Using a table is preferable in this instance. It is possible to lay these things out with CSS but it's a lot of work.



Keep in mind it's very difficult to vertically align objects using CSS you have to use positioning at 50% for top and left, then use a negative margin for left and top



#container {

width:100px;

height:50px;

margin-top: -25px;

margin-left: -50px;

padding:0;

position: absolute;

left: 50%;

top: 50%;

}



hope that helps
osage01
2011-04-19 21:28:05 UTC
Best, most reliable way to do that is with a table. Sorry, but CSS is too variable.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Continue reading on narkive:
Loading...