views:

146

answers:

2

I have a simple HTML form, thus:

<form>
    <p>
        <input type="text" name="text" />
    </p>
    <p class="buttonPara">
        <input type="submit" name="submit" />
    </p>
</form>

and a simple stylesheet, thus:

p.buttonPara
{
    position: relative;
}
p.buttonPara input
{
    position: absolute;
    left: 50px;
}

The submit button fails to respond to the return key unless I remove the class from the

<p class="buttonPara">

Any ideas anyone?

A: 

I'm not sure what you want to accomplish and why you take this approach. Do you want to align the button in the middle of the textfield above?

You could do this without positioning the button element. But that would mean wrapping everything in a container element and setting the width of that element along with the text-align property. Or you could set the width and align properties of the form of course.

mensch
My website is fully "accessible" and button graphics are optional for the user. The "buttonPara" also has a background-image and the button is moved to the right to accommodate it. Those users who chose not to see graphics simply don't get the the stylesheet link, so the button appears in it's normal position. All said, that's not the problem I'm trying to solve.
Moose Factory
So, in that case, why not set the width of the form, or a wrapper div around the submit button, to something desirable and set the "text-align" property of that element to "right" in the scenario where the stylesheet is loaded.Because working around the IE8 bug triggered by your approach might require some JavaScript hacking. Which will leave IE8 users who have disabled JavaScript out in the cold.
mensch
A: 

I worked it out.

My form is contained in a div that has its class set programatically by the body onload event. Until the class is set, the div has an underlying style of display:none. In IE, the result is that hitting the return key does not submit the form.

Moose Factory