
Originally Posted by
_Nikhil
I'm trying to make input form where I have 4 inputs on different rows. I need to have 2 inputs on a row so then there will be only 2 rows.
lol - you lost me at the first hurdle.
That sentence says different things.
If you want two rows with two sets of labels and inputs on the same row you could do it like this:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
.formtest{
width:700px;
margin:auto;
}
.formtest label,formtest input{
display:inline-block;
vertical-align:middle;
}
.formtest label{
width:150px;
text-align:right;
padding:0 10px 0 0;
}
.formtest input{
width:150px;
margin:2px 25px 2px 0;
}
.formtest div{
margin:10px 0;
background:#fcf;
padding:5px 0;
}
.formtest div:nth-child(odd){background:#ffc}
</style>
</head>
<body>
<form name="form1" method="post" action="">
<fieldset class="formtest">
<legend>Form Test</legend>
<div>
<label for="test">label 1:</label>
<input type="text" name="test" id="test">
<label for="test2">another label 2:</label>
<input type="text" name="test2" id="test2">
</div>
<div>
<label for="test3">label 3:</label>
<input type="text" name="test3" id="test3">
<label for="test4">another label 4:</label>
<input type="text" name="test4" id="test4">
</div>
</fieldset>
</form>
</body>
</html>
If on the other hand you just wanted the label and input on a row then do it like this:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
.formtest {
width:400px;
margin:auto;
}
.formtest label, formtest input {
display:inline-block;
vertical-align:middle;
}
.formtest label {
width:150px;
text-align:right;
padding:0 10px 0 0;
}
.formtest input {
width:150px;
margin:2px 25px 2px 0;
}
.formtest div {
margin:10px 0;
background:#fcf;
padding:5px 0;
}
.formtest div:nth-child(odd) { background:#ffc }
</style>
</head>
<body>
<form name="form1" method="post" action="">
<fieldset class="formtest">
<legend>Form Test</legend>
<div>
<label for="test">label 1:</label>
<input type="text" name="test" id="test">
</div>
<div>
<label for="test2">another label 2:</label>
<input type="text" name="test2" id="test2">
</div>
<div>
<label for="test3">label 3:</label>
<input type="text" name="test3" id="test3">
</div>
<div>
<label for="test4">another label 4:</label>
<input type="text" name="test4" id="test4">
</div>
</fieldset>
</form>
</body>
</html>
Bookmarks