tags:

views:

395

answers:

4

Hello all, having my first attempt at rounded corners in a login form. Just doing the layout right now, but having some IE7 troubles. Trying to avoid using conditional statements, but although I can get it displaying perfectly in Firefox 3.5, IE looks to be creating a larger margin on the right and left of my login button. It could be that I'm not structuring this the best way possible, so looking for a little insight from the community. Most of my problems began after trying to round to corners using the method shown. My goal is IE6/7 compatibility.

<div id="credentials">
    <div id="credsheader"><div id="tr"> </div></div>
    <input type="text" class="blurred" id="username" value="USERNAME" /> 
    <input type="password" id="password" class="blurred" value="PASSWORD" />
    <button type="submit" id="login"><img src="./images/login.png" alt="Submit" /></button>
    <div id="credsfooter"><div id="bl"> </div></div>
</div>

div#credentials{
    position: absolute;
    right: 10px;
    top: 10px;
    background-color: #666;
    padding: 0px 5px;
}

div#tr{
    float: right;
    background: url('../images/tr.png');
    background-repeat: no-repeat;
    cursor: default;
}

div#bl{
    float: left;
    background: url('../images/bl.png');
    background-repeat: no-repeat;
    cursor: default;
}

#credsfooter{
    position: absolute;
    bottom: 0px;
    left: 0px;
    height: 6px;
}

#credsheader{
    position: absolute;
    top: 0px;
    right: 0px;
    height: 6px;
}

#username{
    font-family: 'Lucida Sans', Helvetica, Arial, sans-serif;
    font-size: 8pt;
    padding: 3px;
    margin: 8px 3px;
    vertical-align: middle;
}

#password{
    font-size: 8pt;
    padding: 3px 3px 4px 3px;
    margin: 8px 17px 8px 3px;
    vertical-align: middle;
}

input.blurred{
    color: #AAA;
}

input.focused{
    color: #000;
}

#login{
    background: transparent;
    border: 0px;
    padding: 4px 0px 2px 0px;
    margin: 0px -12px;
    cursor: pointer;
    vertical-align: middle;
}
A: 

Not sure if this is the case, but it could be the 'IE Double Margin Bug'.

From memory, I think it might be worth trying to add display: inline; to your floated elements?

Good Luck!

Chris Roberts
Wow, surprisingly this did not work, but it seems like it should. It looks as if the margin is doubled in IE7. Really good to know, though.
lush
Ah well - it was worth a shot! CSS isn't really my thing, but thought I'd mention it in case it was a quick win for you! Good luck!
Chris Roberts
Definitely sure I'll need that later, though.
lush
A: 

That's difficult to answer that without viewing the HTML in action (with images, for example). Could you set a sample page up somewhere?

Theoretically, it could be a case of not having hasLayout for your button element. You can add the position: relative CSS style to the button element and see if it works. Alternatively, it could be a case of negative horizontal margins (IE does not like them sometimes).

Vlad Andersen
A: 

Ok so I found a lot of problems cause by browser inconsistencies which were causing you a whole lot of problems so I basically started over. I hate forms because of inconsistencies so this was a learning experience for me. I was able to really consolidate the CSS because a lot of it was used to compensate for weird padding and margins. The main thing was I used an input element for a button instead of a button because it is more consistent across browsers. I also added a form tag to fix any issues there. Note that the <p> in the form is intentional. I also added an reset.css file that makes a huge difference because It resets all elements to a state that is consistent to all browsers.

Below is the re written-code:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Buttons Suck in IE7!</title>
        <link rel="stylesheet" href="reset.css" type="text/css" />
        <style type="text/css">
            #credentials{
                position: absolute;
                right: 10px;
                top: 10px;
                background-color: #666666;
                padding: 10px;
                -moz-border-radius: 5px;
            }

            input.text-input{
                font-family: 'Lucida Sans', Helvetica, Arial, sans-serif;
                border: 1px solid black;
                vertical-align: middle;
                height: 20px;
                width: 140px;
                color: #AAAAAA;
            }

            input.text-input:focus{
                color: #000000;
            }

            input#login{
                background: transparent;
                border: 0px;
                height: 20px;
                cursor: pointer;
                vertical-align: middle;
            }
        </style>
    </head>
    <body>
        <div id="credentials">
            <form action="http://www.site.com/login.php"&gt;
                <p>
                    <input type="text" class="blurred text-input" id="username" value="USERNAME" />
                    <input type="password" class="blurred text-input" id="password"  value="PASSWORD" />
                    <input id="login" type="image"
                           src="http://www.axialis.com/objects/users-home.jpg"
                           name="submit" value="Button Text" />
                </p>
            </form>
        </div>
    </body>
</html>

Note that the image I used for the button is some random image I found on Google! You probably also notice that I used -moz-border-radius: 5px; for the rounded corners. This was for simplification. What you can do is take a screen shot of the credentials box in Firefox and then crop just the box out in your favorite image editor. Next you would fill in the inputs with the gray color using some sort of paint brush tool. Now you would have a blank gray box of the same shape and size. Now all you have to do is set that as the background image of your credentials box. That's a lot simpler then do each corner at a time! Don't forget to get rid of -moz-border-radius: 5px; after you do this.

Oh, and before I forget here is reset.css:

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { 
        margin:0;
        padding:0;
}
table {
        border-collapse:collapse;
        border-spacing:0;
}
fieldset,img { 
        border:0;
}
address,caption,cite,code,dfn,em,strong,th,var {
        font-style:normal;
        font-weight:normal;
}
ol,ul {
        list-style:none;
}
caption,th {
        text-align:left;
}
h1,h2,h3,h4,h5,h6 {
        font-size:100%;
        font-weight:normal;
}
q:before,q:after {
        content:'';
}
abbr,acronym { border:0;
}

Include this reset.css on every page its a lifesaver trust me. Oh and one last note. input.text-input:focus{} probably wont work in IE6 or 7, it will only work on tags. But don't worry because I think IE6 has a limited lifespan at this point.

I hope That helped...good luck!

UPDATE: I tested this on IE 5.5-8 and it looks the same on every one, the only problem is :focus only works in IE8 for input tags.

teh_noob
A: 

Got acceptable margins, but still not perfect cross browser. Just spent time manipulating margin sizes in pixels until it didn't look terrible.

lush