I have problem with floating on contact page. Here is the following code.
HTML
<div class="contact">
<form class="form" method="post" action="">
<table>
<tr>
<td class="contact-firstcol">
<label for="name">Name</label>
</td>
<td class="contact-secondcol">:</td>
<td class="contact-thirdcol">
<input type="text" name="name" id="name" />
</td>
</tr>
<tr>
<td class="contact-firstcol">
<label for="email">Email</label>
</td>
<td class="contact-secondcol">:</td>
<td class="contact-thirdcol">
<input type="text" name="email" id="email" />
</td>
</tr>
<tr>
<td class="contact-firstcol">
<label for="phone">Phone</label>
</td>
<td class="contact-secondcol">:</td>
<td class="contact-thirdcol">
<input type="text" name="phone" id="phone" />
</td>
</tr>
<tr>
<td class="contact-firstcol">
<label for="topic">Topic</label>
</td>
<td class="contact-secondcol">:</td>
<td class="contact-thirdcol">
<div class="styled-select select">
<select class="dropdown">
<option value="generalQuestion">General Question</option>
</select>
</div>
</td>
</tr>
<tr>
<td class="contact-firstcol">
<label for="message">Message</label>
</td>
<td class="contact-secondcol">:</td>
<td class="contact-thirdcol">
<textarea id="message" name="message"></textarea>
</td>
</tr>
<tr>
<td class="contact-firstcol"></td>
<td class="contact-secondcol"></td>
<td class="contact-thirdcol">
<input type="reset" name="reset" value="CLEAR" />
<input type="submit" name="submit" value="SUBMIT" />
</td>
</tr>
<table>
</form>
</div>
<div class="aside">
<p>Email</p>
<p>Telephone</p>
<p>Address</p>
</div>
CSS
.contact {
float:left;
width:68%;
margin:20px 0 0 0;
padding:10px;
}
.aside {
float:left;
width:27%;
margin:20px 0 0 0;
padding:10px;
background-color:#CECECE;
}
#home-contact p {
font-family:'alegreya_sansregular';
letter-spacing:0;
}
table {
line-height:30px;
margin:20px;
display:inline-block;
}
td {
vertical-align:top;
}
.contact-firstcol {
font-family:'alegreya_sansregular';
width:100px;
font-size:17px;
color:#999;
}
.contact-secondcol {
font-family:'alegreya_sansregular';
width:20px;
text-align:center;
font-size:17px;
color:#999;
}
.contact-thirdcol {
width:300px;
color:#999;
}
.form {
margin-top:20px;
}
.form input, textarea {
padding: 5px;
margin: 2px 5px;
border: solid 1px #E5E5E5;
outline: 0;
font: normal 12px/100% Verdana, Tahoma, sans-serif;
width: 280px;
background: -webkit-gradient(linear, left top, left 25, from(#FFFFFF), color-stop(4%, #EEEEEE), to(#FFFFFF));
background: -moz-linear-gradient(top, #FFFFFF, #EEEEEE 1px, #FFFFFF 25px);
box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;
-moz-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;
-webkit-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;
max-height:300px;
resize:none;
}
.form textarea {
width:280px;
max-width:280px;
height:100px;
max-height:100px;
line-height:150%;
}
input[type="submit"], input[type="reset"] {
color:#FFF;
background:rgba(100, 100, 100, 1);
border:none;
width:100px;
letter-spacing: 1px;
font-family:'alegreya_sansregular', sans-serif;
font-size:17px;
cursor:pointer;
}
input[type="submit"]:hover, input[type="reset"]:hover {
background:rgba(100, 100, 100, 0.5);
-o-transition:.5s;
transition:.5s;
-ms-transition:.5s;
-moz-transition:.5s;
-webkit-transition:.5s;
}
.styled-select select {
width:293px;
padding-top:2px;
color:#999;
margin-left:5px;
border:1px solid #CCC;
height:28px;
font-size:15px;
background: -webkit-gradient(linear, left top, left 25, from(#FFFFFF), color-stop(4%, #EEEEEE), to(#FFFFFF));
background: -moz-linear-gradient(top, #FFFFFF, #EEEEEE 1px, #FFFFFF 25px);
box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;
-moz-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;
-webkit-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;
}
-webkit-appearance: none;
}
.styled-select {
width: 240px;
height: 34px;
overflow: hidden;
background: url(../images/arrowdown.png) no-repeat right #ddd;
border: 1px solid #ccc;
}
Can you help how to fix this?
I want to make .contact and .aside float left very well. But it turned out that .aside didn't float at all, and stay at .contact.
I tried to removed one by one and I spotted after I removed table tag, it's working well. But as soon as I insert table tag, it didn't work at all..
And here is JSFIDDLE for you to understand more clearly.
Thanks! Looking forward to hear from you!
IF you resize the window on your jfiddle to allow for more space on the actual display you'll see that if you make it big enough it will float left as you expect. I think the issue is the widths you have set as if there is not enough room. If there is not enough room for an element to float, it will be placed below the other element or "wrap to the next line" as it were.
edit: Props to pankaj for noticing that yout table closing tag was missing the / (</table>) for cleanliness, though it Shoudln't have affected the div floats.
There was a small typo in the code that you shared. The closing tag of table wasn't proper. Check that.
Also, since you have given width in %age along with some padding for both .aside and .contact, it is messing with the calculation.
If I remove the padding from both .aside(32% width) and .contact(68% width), the divs are coming side by side. You can create another internal div to give proper padding.
Updated your jsfiddle link - http://jsfiddle.net/28CEE/1/
Here is the modified css:
.contact {
float:left;
width:68%;
margin:20px 0 0 0;
}
.aside {
float:left;
width:32%;
margin:20px 0 0 0;
background-color:#CECECE;
}
Be sure to close your </table> in your fiddle. You shouldn't need to change the display property of a table (you have it set to inline-block). As well, you might check your padding properties so they are percentage based (so they match your width units). You could also change the asides float to right.
You can try like this: LINK
HTML:
<div class="aside">
<p>Email</p>
<p>Telephone</p>
<p>Address</p>
</div>
<div class="contact">... </div>
Suppose if you want to float "aside" to right... use float:right instead of left
add css class
.form {
width: 68%;
float: left;
}
set width for contact like (width: 88%;)
close table tag </table>, set a active after form
<div class="contact">
<form class="form" method="post" action="">
<table>
<tr>
<td class="contact-firstcol"> <label for="name">Name</label> </td>
<td class="contact-secondcol"> : </td>
<td class="contact-thirdcol"> <input type="text" name="name" id="name" /> </td>
</tr>
<tr>
<td class="contact-firstcol"> <label for="email">Email</label> </td>
<td class="contact-secondcol"> : </td>
<td class="contact-thirdcol"> <input type="text" name="email" id="email" /> </td>
</tr>
<tr>
<td class="contact-firstcol"> <label for="phone">Phone</label> </td>
<td class="contact-secondcol"> : </td>
<td class="contact-thirdcol"> <input type="text" name="phone" id="phone" /> </td>
</tr>
<tr>
<td class="contact-firstcol"> <label for="topic">Topic</label> </td>
<td class="contact-secondcol"> : </td>
<td class="contact-thirdcol">
<div class="styled-select select">
<select class="dropdown">
<option value="generalQuestion"> General Question </option>
</select>
</div>
</td>
</tr>
<tr>
<td class="contact-firstcol"> <label for="message">Message</label> </td>
<td class="contact-secondcol"> : </td>
<td class="contact-thirdcol"> <textarea id="message" name="message"></textarea> </td>
</tr>
<tr>
<td class="contact-firstcol"></td>
<td class="contact-secondcol"></td>
<td class="contact-thirdcol"> <input type="reset" name="reset" value="CLEAR" /> <input type="submit" name="submit" value="SUBMIT" /> </td>
</tr>
</table>
</form>
<div class="aside">
<p> Email </p>
<p> Telephone </p>
<p> Address </p>
</div>
</div>
Related
I have a large number of inputs I need to display. I am trying to condense them into like groups. The first group I am have is going to have 6 inputs in 3 columns but the third input box is big, so I want the next rows input to line up with the bottom of the larger text box. Form Layout
I have tried to float them, list them, use a table, but all without successs
I have looked at a lot of CSS code snippets and cannot figure out how to get this layout. Any help would be greatly appreciated.
Edit: I found a way to make it work, but would like a more elegant solution. HTML:
.row1 {
float: left;
background-color: #ffffff;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
font-family: Raleway, sans-serif;
text-align: center;
text-decoration: none;
padding: 5px;
}
.row2{
float: left;
background-color: #ffffff;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
font-family: Raleway, sans-serif;
text-align: center;
text-decoration: none;
padding: 5px;
}
.row3{
float: left;
display: inline-block;
clear: left;
position: relative;
margin-top: -80px;
}
<div class="row1">
<label>
<span>Full Project Number</span><br>
<input type="text" name="project" id="project">
</label>
</div>
<div class="row1">
<label>
<span>Client</span><br>
<input type="text" name="client" id="client">
</label>
</div>
</div>
<div class="row2 fasttimesatseedmonthigh">
<label id="descrp">
<span>Project Description</span><br>
<textarea name="name" type="text" cols="50" rows="10"></textarea>
</label>
</div>
<div class="row3">
<div class="row1">
<label for="drawing">
<span>Drawing Number</span><br>
<input type="text" name="drawing" id="drawing">
</label>
</div>
<div class="row1">
<label>
<span>Assigned By:</span><br>
<input type="text" name="assigned" id="assigned" style="width: 75px;">
</label>
</div>
<div class="row1">
<label class="form-row">
<span>Date</span><br>
<?php
$stamp=date("Y/m/d");?>
<input type="text" name="date" id="date" value="<?php echo(htmlspecialchars($stamp))?>"/>
</label>
</div>
</div>
It works but like I said not as nice as I would like it.
How about a good ol' table with row&colspan?
.grid{
border: solid 1px black;
table-layout: fixed;
font-family: Raleway, sans-serif;
border-spacing: 10px;
}
.grid td{
text-align: center;
vertical-align: top;
font-size: 9pt;
}
.grid td.wide{
width: 200px;
}
.grid td.normal{
width: 100px;
}
.grid td input{
width: 100%;
}
<table class="grid">
<tr>
<td colspan="2" class="wide">
<label>
<span>Full Project Number</span><br>
<input type="text" name="project" id="project">
</label>
</td>
<td colspan="2" class="wide">
<label>
<span>Client</span><br>
<input type="text" name="client" id="client">
</label>
</td>
<td colspan="2" rowspan="2">
<label id="descrp">
<span>Project Description</span><br>
<textarea name="name" type="text" cols="20" rows="8"></textarea>
</label>
</td>
</tr>
<tr>
<td colspan="1" class="normal">
<label for="drawing">
<span>Drawing Number</span><br>
<input type="text" name="drawing" id="drawing">
</label>
</td>
<td colspan="1" class="normal">
<label>
<span>Assigned By</span><br>
<input type="text" name="assigned" id="assigned">
</label>
</td>
<td colspan="2" class="wide">
<label class="form-row">
<span>Date</span><br>
<input type="text" name="date" id="date">
</label>
</td>
</tr>
</table>
Plis no hate.
I am trying to achieve the below format design in HTML. I tried using multiple TR inside TD but i was not successful in getting the below design.
Please find the below code i have been trying:
#content {
position: absolute;
top: 110px;
left: 350px;
width: 775px;
height: 605px;
}
#content label {
display: block;
float: left;
margin-right: 4px;
vertical-align: top;
}
<div id="content">
<label>
Date Range
</label>
<label>
(Past)
<br />
<input id="myDatePast" type="text" style="width:31px;" />
</label>
<label>
(Future)
<br />
<input id="myDateFuture" type="text" style="width:31px;" />
</label>
<label>
<br />Total
<input id="myDateFuture" type="text" style="width:31px;" />Days
</label>
</div>
Well you can try something like this. I used table and css to style them.
table {
border: 1px solid #666;
border-collapse: collapse;
}
th,tr {width: 150px;}
th input {width: 50px;}
.th1-main {
border-right: 1px solid #666;
}
.th1-modify {margin-left: 60px;}
.th1-modify2 {margin-right: 60px;}
<div id="content">
<table>
<tr>
<th class="th1-main">
<span class="th1-modify">Date</span> <br>
<span class="th1-modify2">Range</span>
</th>
<th>
Past<br>
<input type="text" value="60"><br>
Date
</th>
<th>
Future<br>
<input type="text" value="360"><br>
Date
</th>
<th>
Total - <input type="text" value="420"> days
</th>
</tr>
</table>
</div>
Hope this was helpful.
table,#cell1{
border:2px solid gray;
border-collapse: collapse;
}
#total{
width:auto;height:50px;
}
#cell1{
width:100px;
height:75px;
}
td:not(.empty){
width:100px;
height:50px;
}
<div id="content">
<table>
<tr>
<td id="cell1">
<span style="float:right"><b>Date</b></span><br/><br/>
<span style="float:left"><b>Range</b></span> </td>
<td class="empty"></td>
<td>
(Past)
<br/>
<input id="myDatePast" type="text" value="60" style="width:31px;" /><br/><b>Date</b>
</td>
<td>
(Future)<br/>
<input id="myDateFuture" type="text" value="360" style="width:31px;" /><br/><b>Date</b>
</td>
<td id="total">
Total-
<input id="myDateFuture" type="text" value="420" style="width:31px;"/><b> Days</b>
</td>
</table>
</div>
A good setup would be
<table>
<tr>
<td>2</td><td>2</td>
</tr>
<tr>
<td>3</td><td>4</td>
</tr>
<tr>
<td>5</td><td>6</td>
</tr>
</table>
I am trying to float the submit button to the right in the form but I am facing problem the float is not being applied on the submit button Login. I have added some of server-side generated code.
Code
#login-form{
width: 400px;
background-color: #6B0000;
color: white;
}
#loginButton{
color: #6B0000;
border: 1px solid;
padding: 5px 30px 5px 30px;
background-color: white;
border-radius: 3px;
/*This one here does not work */
float: right;
}
<body>
<header id="header">
<h1>
Google Maps & Yahoo Mashup
</h1>
</header>
<DIV id="content">
<form id="login-form" name="login-form" method="post" onSubmit='return false'>
<input type="hidden" name="login-form" value="login-form" />
<table>
<tbody>
<tr>
<td><label>Email</label></td>
<td><input id="login-form:email" type="text" name="login-form:email" /></td>
</tr>
<tr>
<td><label>Password</label></td>
<td><input id="login-form:pwd" type="text" name="login-form:pwd" /></td>
</tr>
<tr>
<td><input type="submit" value="Login" id="loginButton" /></td>
</tr>
</tbody>
</table>
<input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" />
</form>
</DIV>
</body>
Try this one. I set a colspan of 2 to the input button and gave its parent td a width of 100%, this along with the float right should shift it to the right.
#login-form{
width: 400px;
background-color: #6B0000;
color: white;
}
#loginButton{
color: #6B0000;
border: 1px solid;
padding: 5px 30px 5px 30px;
background-color: white;
border-radius: 3px;
/*This one here does not work */
float: right;
}
/* Make the input's parent td 100%, you may want
a class here instead for browser support */
td:last-child {
width: 100%;
}
<body>
<header id="header">
<h1>
Google Maps & Yahoo Mashup
</h1>
</header>
<DIV id="content">
<form id="login-form" name="login-form" method="post" >
<input type="hidden" name="login-form" value="login-form" />
<table>
<tbody>
<tr>
<td><label>Email</label></td>
<td><input id="login-form:email" type="text" name="login-form:email" /></td>
</tr>
<tr>
<td><label>Password</label></td>
<td><input id="login-form:pwd" type="text" name="login-form:pwd" /></td>
</tr>
<tr>
<!-- setting a colspan of two -->
<td colspan="2"><input type="submit" value="Login" id="loginButton" /></td>
</tr>
</tbody>
</table>
<input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" />
</form>
</DIV>
</body>
The title is a bit fuzzy, but here is want I want. I created a register form. I want the two error messages to be displayed next to the two input boxes but outside the whole form. Everything you see in the middle is in one div that is horizontally aligned to center.
I don't know if using the top property(%) can help placing them vertically but then I still need to align them to the right of the form.
Code:
<div id="container">
<div id="container_center">
<form name="RegForm" method="post" action="/validate_register2.php" onsubmit="getDatum()">
<table class="minden2">
<tr>
<td>
<h1 class="title">Register</h1>
</td>
</tr>
<tr>
<td>
<table class="cont2">
<tr>
<td class="hely">
<p><b>Username:</b></p>
</td>
</tr>
<tr>
<td>
<input type="text" name="username" class="aaa" id="form_username" maxlength="25" value="">
</td>
</tr>
<tr>
<td class='reg'>
<p class='le'><b>Password:</b></p>
</td>
</tr>
<tr>
<td>
<input class="tooltip" type="password" name="password1" id="form_password1" maxlength="25" value="">
</td>
</tr>
<tr>
<td class="reg">
<p class='le'><b>Email:</b></p>
</td>
</tr>
<tr>
<td>
<input type="text" name="email1" class="i" id="form_email1" maxlength="254" value="">
</td>
</tr>
<tr>
<td>
<label id="c"><input type="checkbox" name="cb" id="acceptagreement" class="cb" onchange="enableSubmitButton()"/>I have read and
agreed to the Terms of use and Privacy Policy.</label>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="submit">
<input type="submit" name="submit" value="Register" id="submit" class="submitbtn"/>
</td>
</tr>
</table>
</form>
<p id='error1' >Error message 1<p>
</div>
</div>
#container {
border: 0px solid green;
margin:0;
}
#container_center{
border: 0px solid black;
width: 320px;
height: auto;
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 40px;
background: #FFFFFF;
padding: 20px;
padding-bottom:15px;
padding-top:0;
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
-o-border-radius: 10px;
-khtml-border-radius: 10px;
-webkit-box-shadow:0 0px 10px rgba(0, 0, 0, 0.5);
-moz-box-shadow:0 0px 10px rgba(0, 0, 0, 0.5);
box-shadow:0 0px 10px rgba(0, 0, 0, 0.5);
}
table.minden2 {
border:0px solid red;
border-collapse: collapse;
margin:0;
text-align:center;
width: 100%;
}
Full code available here:
http://www55.zippyshare.com/v/84179336/file.html
http://www63.zippyshare.com/v/98322849/file.html
You could use the fact that overflow can be displayed outside the parent div using a row div with wrapping disabled
white-space: nowrap;
and fixing the width of the container to the the desired amount.
See this example http://jsfiddle.net/sk96t/3/
You can notice that changing font size or spacing between the fields the error message keeps the vertical alignment.
Assuming the error messages come just before or after their associated form field, you could float the error messages right and give them a negative right margin. That will pull them outside of the containing div. Then you can play with the top margin on the error messages to get the vertical offset you're looking for. Just make sure overflow is visible on the containing div, or you'll hide the messages when they're shifted right.
If you want the two error messages to be displayed next to the two input boxes but outside the whole <form>, you can do it by placing your <form> tag just outside your <div> tag.
Show your code.
i have no problems seeing the page in IE or Chrome and the Upload button works in both.. but in FireFox it doesnt displat the widths correctly nor does the upload button works..
i cant seem to find anythiong wrong with the code... here is the entire page
<!DOCTYPE html>
<html>
<head>
<style>
*{
margin:0;
padding:0;
font-family:verdana;
color:#3f3f3f;
font-size:14px;
}
html,body{
height:100%;
}
#container{
width:1024px;
margin:0 auto;
height:100%;
}
#content{
min-height:100%;
background-color:#fff;
width:804px;
padding:5px;
float:left;
display:inline;
-moz-border-radius: 10px;
border-radius: 10px;
margin-right:10px;
}
body{
background-color:rgb(228, 228, 228);
}
table{
width:450px;
margin:0 auto;
}
table td{
padding:10px 5px;
}
table th{
background-color:rgb(116, 116, 116);
color:#fff;
padding:10px;
text-align:left;
font-weight:normal;
font-size:16px;
}
table label{
display:block;
padding-bottom:3px;
font-weight:bold;
}
table input[type=text], table select{
display:block;
color:rgb(116, 116, 116);
padding:8px;
line-height:20px;
border:1px solid rgb(183, 187, 202);
font-weight:bold;
vertical-align: middle;
background-color:rgb(255, 255, 255);
width:260px;
}
table select{
width:277px;
}
#txtEmail, #ctitle, #txtDesc{
width:550px;
}
/* Upload Button */
table input[type=file]{
text-align: right;
/* start of transparency styles */
opacity:0;
-moz-opacity:0;
filter:alpha(opacity:0);
/* end of transparency styles */
z-index:2;
cursor:pointer;
}
#fileName{
width:196px;
display:inline;
margin:0;
}
.uploadbtn{
display:block;
padding:0;
margin:0;
font-weight:normal;
width:60px;
display:inline-block;
height:38px;
line-height:38px;
vertical-align:middle;
background-color:#3f3f3f;
color:#fff;
text-align:center;
float:right;
cursor:pointer;
}
/*********************/
</style>
</head>
<body>
<div id="container">
<div id="content">
<table cellpadding="0" cellspacing="0">
<tr><th colspan="2">Informacion de Contacto</th></tr>
<tr>
<td>
<label>Nombre</label><input type="text" maxlength="20" id="txtName" name="txtName"/>
</td>
<td>
<label>Apellido</label><input type="text" maxlength="20" id="txtLastName" name="txtLastName"/>
</td>
</tr>
<tr>
<td>
<label>Telefono</label><input type="text" maxlength="13" id="txtTel1" name="txtTel1"/>
</td>
<td>
<label>Telefono Adicional</label><input type="text" maxlength="13" id="txtTel2" name="txtTel2"/>
</td>
</tr>
<tr>
<td colspan="2">
<label>Email</label><input type="text" maxlength="100" id="txtEmail" name="txtEmail"/>
</td>
</tr>
<tr><th colspan="2">Informacion del Clasificado</th></tr>
<tr>
<td colspan="2">
<label>Titulo</label><input type="text" maxlength="100" id="ctitle" name="ctitle"/>
</td>
</tr>
<tr>
<td colspan="2">
<label>Descripcion</label><textarea name="cbody" cols="78" rows="10" id="cbody" ></textarea>
</td>
</tr>
<tr>
<td>
<label>Precio</label><input type="text" maxlength="9" id="txtPrecio" name="txtPrecio"/>
</td>
<td>
<label>Comentario (OMO,FIJO,etc)</label><input type="text" maxlength="10" id="txtPriceComment" name="txtPriceComment"/>
</td>
</tr>
<tr>
<td>
<label>Tipo de Clasificado</label>
<select>
<option>Venta</option>
<option>Adopcion</option>
</select>
</td>
<td>
<label>Categoria</label>
<select>
<option>Perros</option>
<option>Gatos</option>
</select>
</td>
</tr>
<tr>
<td>
<label>Pueblo</label>
<select>
<option>Area Metro</option>
<option>Bayamon</option>
</select>
</td>
<td>
<label>Foto</label>
<input type="text" maxlength="100" id="fileName" name="fileName"/>
<label class="uploadbtn">Upload
<input type="file" name="userfile" size="20" onchange="javascript: document.getElementById('fileName').value = this.value"/>
</label>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
What's happening is that each browser renders input file element differently and Firefox is rendering your input file away from your label. So when you click on your label, you are not clicking on input file. Am I being clear?
Please see this tutorial how to create a custom input file cross browser compatible.
http://www.quirksmode.org/dom/inputfile.html
Let me know if this helped you
You shouldn't forget the mime type on your stylesheet
<style></style>
to
<style type="text/css"></style>