Log in

View Full Version : Resolved Input type error cross browser layout



davelf
03-07-2011, 07:29 AM
Hi, i have problem with google chrome:
I make an input box for login, it should look like this one in FF:
http://www.dynamicdrive.com/forums/attachment.php?attachmentid=3790&stc=1&d=1299482701

But it appear like this in chrome, safari, & IE.7
http://www.dynamicdrive.com/forums/attachment.php?attachmentid=3791&stc=1&d=1299482723

This is input code:


<input type="image" class="login" onclick="javascript:ajaxpage('content/do-login.html', 'kolomlogin');"/>


This is the CSS:


.login {
display: block;
width: 67px;
height: 32px;
background: url('images/button/login.png') bottom;
}
.login:hover {
background-position: 0 0;
}


And This is the Image:
http://www.dynamicdrive.com/forums/attachment.php?attachmentid=3792&stc=1&d=1299482893

So is there any problem with my css code?
Thank you for your attention:D

Beverleyh
03-07-2011, 10:53 AM
What if you just add value="" to the login button input tag?

davelf
03-08-2011, 02:48 AM
ya i already try that too, it's not work.:p

davelf
03-08-2011, 02:51 AM
I used this line of code to cover it:


<a href="#" class="login" onclick="javascript:ajaxpage('content/do-login.html', 'kolomlogin');"></a>

i try this to :

<input type="file" class="login" onclick="javascript:ajaxpage('content/do-login.html', 'kolomlogin');"/>
but this doesn't work either.

is that mean that i can't use image for my button. Or like my first question, is there any problem the way i call the css sprite?:cool:

djr33
03-08-2011, 02:59 AM
I believe that an image input uses the src attribute just like a regular img tag.
Try adding this to the tag:
src="yourimage.jpg"

I'm not sure how you can have the special styling and the image, but it should work to at least remove the default text.

davelf
03-08-2011, 04:43 AM
the reasons that i using "class" instead direct "src" is the hover.
That's why i use css sprite too, hehe

So any other option:p

jscheuer1
03-08-2011, 09:21 AM
djr33 is right. You need a src attribute. The reason it looks different in Firefox is that in Firefox, the broken image token isn't displayed as frequently (in less situations) as it is in other browsers. For what you are doing a transparent .gif image may be used. That way there should be no broken image token:


<input src="transparent_67_32.gif" type="image" class="login" onclick="javascript:ajaxpage('content/do-login.html', 'kolomlogin');"/>

For best results, make this transparent .gif conform to the dimensions:



.login {
display: block;
width: 67px;
height: 32px;
background: url('images/button/login.png') bottom;
}
.login:hover {
background-position: 0 0;
}

Like:

http://home.comcast.net/~jscheuer1/side/transparent_67_32.gif

It's there, you just can't see it. If you hover over it, you may right click and save it. Or use this link:

http://home.comcast.net/~jscheuer1/side/transparent_67_32.gif

You still won't be able to see it. Or use this:

http://home.comcast.net/~jscheuer1/side/transparent_67_32.htm

where I've put it in a div of the same dimensions and given the div a background color.

jscheuer1
03-08-2011, 03:56 PM
Even better, use a button type input:


<input type="button" class="login" onclick="ajaxpage('content/do-login.html', 'kolomlogin');"/>

css:


.login {
display: block;
width: 67px;
height: 32px;
background: url('images/button/login.png') bottom;
border-width: 0;
}
.login:hover {
background-position: 0 0;
}

Notes:


For the onclick event of an element, the prefix javascript: is not required.


No transparent .gif is needed.


Since no image is involved, display: block; could be removed, unless you need the line breaks.

davelf
03-09-2011, 02:27 AM
ah i understand now that's what Daniel mean.

Thanks you so much John, it's perfect.