Forum Moderators: not2easy

Message Too Old, No Replies

any way I can make css "attached" to the bottom of a form field?

         

partha

7:50 pm on Jan 9, 2005 (gmt 0)

10+ Year Member



I'd like to have a block of CSS attached or "stuck on" to the bottom of a text input field in a form. I have several of these. So in other words, how can I make my little block of CSS right next to the bottom of the form field, and the same width?

createErrorMsg

3:29 am on Jan 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



my little block of CSS

I think there is some confusion in your wording. CSS is a styling language. Lines of CSS code are placed either in a style attribute within an HTML tag (called inline styles), within <style></style> tags in the <head> of your document (called internal styles), or in an external .css file that is linked to the document via the <link> tag (called external styles). The lines of CSS code do not actually produce content on the page (except in very rare and not widely supported exceptions), but instead instruct the browser on HOW it should render the content in the HTML source code.

When you say "little block of CSS," and say that you would like to place it somewhere on your page, what exactly is it that you are referring to?

cEM

partha

4:15 am on Jan 10, 2005 (gmt 0)

10+ Year Member



sorry I mean content. I just mean is there a way using CSS to attach a little box of content to the bottom of a text input field?

createErrorMsg

1:32 pm on Jan 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are many ways to use CSS to position elements on the page. Most of them involve a mix of CSS code for positioning and making sure that the element is in the right place in the HTML code. A couple questions might help nail down what you need...

1. Do you mean inside the text input, or outside the text input?

2. Do you mean content that is in the HTML code, or not in the HTML code?

3. Can you give a small description of exactly what it is you are trying to do?

cEM

partha

4:16 pm on Jan 10, 2005 (gmt 0)

10+ Year Member



thanks, here's what I'm trying to do:

I have some text input form fields on a page and I just want to make a sort of "help box" for each one. (A little box that gives tips for filling in the text input field)

I'm just trying to figure out the correct CSS to make the help box show up directly under the text input field and with the same width as the text input field.

createErrorMsg

10:05 pm on Jan 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



correct CSS to make the help box show up directly under the text input field and with the same width as the text input field

The keys here would be (a)making sure the help box comes after the text box in the HTML, but within the same container, (b)giving both elements an explicit (and equal) width in the CSS, then (c) floating the hint box to the right so it sits underneath the input box. Try the following code and see if it's what you had in mind...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<style type="text/css">
.box{
width:200px;
text-align:right;
clear:right;
}
.text_input{
width: 100px;
border: 1px solid #123;
}
.hint {
float:right; /*brings hint box underneath input box*/
width:100px;
border:1px solid #123;
background:#789;
text-align:left;
margin-top:0px; /*removes the gap*/
}
</style>
</head>
<body>
<div class="box">
<label>First Name: <input type="text" class="text_input" name="first_name" value="your first name" />
<p class="hint">Hint: Check your driver's license if you're not sure how to spell your first name!</p>
</div>
<div class="box">
<label>Age: <input type="text" class="text_input" name="first_name" value="your age" />
<p class="hint">Hint: This is a number, like "21," and not a word, like "fish."</p>
</div>
</body>
</html>

Be sure to add a clear:right property to whatever follows this block of code (each .box div has it so they will stack) or funky things will happen.

cEM

partha

5:01 pm on Jan 11, 2005 (gmt 0)

10+ Year Member



hm well that does something pretty strange in ie6.

here's the important parts of my code:

------
<style type="text/css">
<!--

.row{
padding: 15px 0 15px 0;
clear:both;
display:block;
border-bottom: 1px solid silver;
}

.field{
display: inline;
clear: right;
text-align:right;
}

.hint{
display: block;
float:right;
margin-top:0px; /*removes the gap*/
background-color: #E2F6EA;
color: #000;
font-size: 9px;
font-weight: normal;
padding: 5px;
text-align: left;
}

-->
</style>

<body>

<div class="row">

<div class="field">
<label>Phone</label>
<input type="text" name="phone" size="15">
<div class="hint">Please include the area code</div>
</div>

<div class="field">
<label>Fax</label>
<input type="text" name="fax" size="15">
<div class="hint">Please include the area code</div>
</div>

</div>

</body>
---------

it makes the hint show up right beneath each row-line (bottom border of .row)

Storyman

7:30 pm on Jan 11, 2005 (gmt 0)

10+ Year Member



Partha,

I'm using FF and IE6 and have no problem with the code, which makes me wonder why it works on mine and not yours.

Is your IE current with all of the critical updates?

Are you copying & pasting all of createErrorMsg's code, including the DOC TYPE? If you are just copying the coding part and pasting it into your document then things could go strange.

partha

12:16 am on Jan 12, 2005 (gmt 0)

10+ Year Member



well, the code I posted does the same thing when I just have it in it's own html file with nothing else. it looks even more screwed up in opera, but I didn't mention that