5

I'm trying to style a HTML submit button in CSS:

HTML:

<input type="submit" value="Yes" id="popUpYes">

CSS:

#popUpYes
{
  width: 60px;
  height: 30px;
  background-color: black;
}
#popUpYes:hover
{
  background-color: white;
}

The basic style works but the background does not change color on hover.

1
  • Just a warning to anyone reading... for me this problem appears to occur when using the Chrome 'device preview' - this is expected... your finger does not have a hover state on mobile Commented Dec 13, 2018 at 8:38

7 Answers 7

4

Your original code works for me. Be sure you don't have any other conflicting styles inherited by the submit button.

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

Comments

3

Try this JSfiddle

Try this:

#popUpYes {
  width: 60px;
  height: 30px;
  background-color: black;
  color: white;
  /* SET COLOR IN WHITE */
}

#popUpYes:hover {
  background-color: white;
  color: black;
  /* SET COLOR IN BLACK */
}
<input type="submit" value="Yes" id="popUpYes">

You have to assign the color - attribute for the text.

Comments

2

I tried this in Chrome and it worked.

#popUpYes {
  width: 60px;
  height: 30px;
  background-color: black;
  color: #fff;
}

#popUpYes:hover {
  background-color: white;
}
<input type="submit" value="Yes" id="popUpYes">

Comments

0

As per your question "The basic style works but the background does not change color on hover." , this happens only when you set your BackColor or background-color through properties. your code works fine because you have used css class instead of properties.

Comments

0

The code as it is now working -> http://jsfiddle.net/2wYqd/ What is your browser?

#popUpYes {
  width: 60px;
  height: 30px;
  background-color: black;
}
#popUpYes:hover {
  background-color: white;
}

Comments

0

My work may be of use to you in this regard.

input[type=submit] {
  background-color: #42b72a;
  color: white;
  border: 5px solid #42b72a;
  width: 200px;
}

#kayitol:hover {
  box-shadow: 0 0 10px #0099ff;
  font-weight: bold;
  color: black;
}

input[type=reset] {
  background-color: #FF8A80;
  color: white;
  border: 5px solid #FF8A80;
  width: 120px;
}

#iptal:hover {
  box-shadow: 0 0 10px #FF3C41;
  font-weight: bold;
  color: black;
}
<input type="submit" id="kayitol" value="Kayıt Ol">
<input type="reset" id="iptal" value="Vaz Geçtim">

2 Comments

Perhaps you could provide more information as to why this would be the answer to the question. What does the code do etc.
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

Working fine link

#popUpYes {
   width: 60px;
   height: 30px;
   background-color: black;
   color:white;
}
#popUpYes:hover {
   background-color: white;
   color: black;
}

Comments

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.