0

I'm attempting to style a button with CSS. Here is the HTML code for the button:

<button class='custombtn' name="doLogin" type="submit" id="doLogin3" value="Login">Login</button>

Here is the CSS code.

.custombtn {
    width:163px;
    height:43px;
    background-image:url('images/normal.png');
    background-color:#d3d3d3;
}
.custombtn:hover {
    background-image:url('images/hover.png');
}
.custombtn:active {
    background-image:url('images/click.png');
}

I thought everything was fine & dandy, until I viewed the results. Instead of something like this with text on it:

enter image description here

It looks like this:

enter image description here

I've been reading fixes for these online for around an hour and a half, however none of them have worked. I know it's possible to style it to look like this, I just need to find a way.

normal.png

enter image description here

hover.png

enter image description here

click.png

enter image description here

3 Answers 3

1

You need to explicitly set border:none; background-color:transparent; on .custombtn.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, is there any way to Style the button upon click?
:hover will apply to the button anytime the mouse cursor is over it. :active will apply to the button as long as the mouse button is held down on it.
1

You need to set the border to none. That should definitely solve the problem and make sure there is no white space in the image itself.

Comments

0

I think the button's background and borders are the cause of your headache.

Try something like this:

.custombtn {
    margin: 10px;
    width:163px;
    height:43px;
    background-image:url('images/normal.png');
    background-color: transparent;
    border: none;
}
.custombtn:hover {
    background-image:url('images/hover.png');
}
.custombtn:active {
    background-image:url('images/click.png');
}​

1 Comment

none is not a valid CSS color value. You want transparent instead. developer.mozilla.org/en-US/docs/CSS/color_value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.