HTML/CSS输入按钮样式不起作用

Jon*_*Jon 6 html css button

我有一个按钮:

在此输入图像描述

在此输入图像描述 关闭

这是CSS:

.searchButton {
  height: 31px;
  width: 33px;
  cursor: pointer;
  border: none;
  background:url(../img/searchButton-Off.png) no-repeat;
}

.searchButton:hover {
  height: 31px;
  width: 33px;
  cursor: pointer;
  border: none;
  background:url(../img/searchButton-On.png) no-repeat;
}
Run Code Online (Sandbox Code Playgroud)

这是HTML:

  <div class="searchBox">
    <h2 style="color:000000;">Search</h2>
    <form id="form_297586" class="appnitro"  method="get" action="results.php">
      <input id="keywords" name="keywords" class="searchBar" title="What do you like...?" type="text" maxlength="255" value=""/>
      <input type="button" class="searchButton" />
      <input type="hidden" name="form_id" value="297586" />
    </form>
  </div>
Run Code Online (Sandbox Code Playgroud)

这是我的浏览器呈现的内容:

在此输入图像描述 苹果浏览器 在此输入图像描述 歌剧

当我鼠标悬停按钮时,它正确切换,然后将显示整个按钮.我不确定为什么会发生这种情况.

思考?

Tim*_*ler 7

按钮有很多默认样式.考虑实现重置样式表,例如:

Eric Meyer的重置

Normalize.css

此外,必须将元素设置为display: block或显示:inline-block以便能够在其上设置尺寸.

最后,我建议您将问题的简化示例放入JSFiddleDabblet,以便人们更容易帮助您.

希望这可以帮助!

编辑:现在我可以看到你的例子,问题是bootstrap.css中的默认样式比你的样式具有更高的特异性.就像是:

input.searchButton
Run Code Online (Sandbox Code Playgroud)

应该解决问题.