Solved

css float

Posted on 2014-02-21
4
234 Views
Last Modified: 2014-02-21
HI,

I have the following code

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Documento sin título</title>

<link href="test.css" rel="stylesheet">

</head>

<body>
<table width="350" border="1" cellspacing="1" cellpadding="2">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
<form id="form1" name="form1" method="post">
  <label for="textfield">Text Field:</label>
  <input type="text" name="textfield" id="textfield">
  <label for="email">Email:</label>
  <input type="email" name="email" id="email">
  <label for="password">Password:</label>
  <input type="password" name="password" id="password">
</form>
<p>&nbsp;</p>
</body>
</html>

Open in new window


and for css
@charset "UTF-8";
/* CSS Document */
#form1{
	float:right'
}

Open in new window


I want the form appears to the right of the table
0
Comment
Question by:joyacv2
  • 2
  • 2
4 Comments
 
LVL 30

Expert Comment

by:renazonse
ID: 39878021
you need to surround your table with a div and then you have to set the widths on the divs. If you don't set the widths it doesn't know where to float.
0
 
LVL 1

Author Comment

by:joyacv2
ID: 39878034
updated code, don't work

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Documento sin título</title>

<link href="test.css" rel="stylesheet">

</head>

<body>
<div width="300px">
<table width="350" border="1" cellspacing="1" cellpadding="2">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table></div>
<form id="form1" name="form1" method="post">
  <label for="textfield">Text Field:</label>
  <input type="text" name="textfield" id="textfield">
  <label for="email">Email:</label>
  <input type="email" name="email" id="email">
  <label for="password">Password:</label>
  <input type="password" name="password" id="password">
</form>
<p>&nbsp;</p>
</body>
</html>

Open in new window

0
 
LVL 30

Accepted Solution

by:
renazonse earned 500 total points
ID: 39878071
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Documento sin título</title>

<link href="test.css" rel="stylesheet">
<style>
/* CSS Document */
#container { width:525px; margin: 10 auto 0 auto; }
#theTable { width:350px; float: left; }
#theForm{
	float:right;
	width:150px;
}
</style>
</head>

<body>
<div id="container">
<div id="theTable">
<table width="350" border="1" cellspacing="1" cellpadding="2">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table></div>
<div id="theForm">
<form id="form1" name="form1" method="post">
  <label for="textfield">Text Field:</label>
  <input type="text" name="textfield" id="textfield">
  <label for="email">Email:</label>
  <input type="email" name="email" id="email">
  <label for="password">Password:</label>
  <input type="password" name="password" id="password">
</form>
</div>
<p>&nbsp;</p>
</div>
</body>
</html>

Open in new window

0
 
LVL 1

Author Closing Comment

by:joyacv2
ID: 39878128
works perfect!!!!!!!!!!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now