Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 按钮悬停时设置动画以从上到下更改颜色_Html_Css_Animation_Button - Fatal编程技术网

Html 按钮悬停时设置动画以从上到下更改颜色

Html 按钮悬停时设置动画以从上到下更改颜色,html,css,animation,button,Html,Css,Animation,Button,我想要的是鼠标悬停时从上到下改变按钮的背景色。这一页上有一个很好的例子 这就是我现在的代码。谢谢 CSS HTML 询问 这是一种方法,就像在网站上一样: CSS: 希望这有帮助!祝你圣诞快乐:-)有很多方法可以做到这一点。 这个css可以帮助你 #button { /*Reset*/ display: inline-block; outline: none; background-color: transparent; /*Some fancy stuff*/ pa

我想要的是鼠标悬停时从上到下改变按钮的背景色。这一页上有一个很好的例子 这就是我现在的代码。谢谢

CSS

HTML

询问

这是一种方法,就像在网站上一样:

CSS:


希望这有帮助!祝你圣诞快乐:-)

有很多方法可以做到这一点。 这个css可以帮助你

#button {

  /*Reset*/
  display: inline-block;
  outline: none;
  background-color: transparent;

  /*Some fancy stuff*/
  padding: 0 20px;
  line-height: 200%;
  border: 1px solid silver;

  /*Magic*/
  background-image: linear-gradient(PaleVioletRed, PaleVioletRed 50%, Sienna 50%, Sienna);
  background-size: 100% 200%;
  -webkit-transition: background-position .3s;
  transition: background-position .3s;
}
#button:hover {
  background-position: 0 -100%;
}

演示:

您的HTML标记在哪里?还请创建一个演示,介绍您迄今为止所做的工作,以便我们查看。我将如何将此应用于我的代码?对不起,我改了,现在应该可以用了!我怎样才能改变背景的颜色,谢谢。第一种颜色是淡紫色,第二种是西耶纳。你可以改变它们。
  <button id="button" />Ask</button>
button {
    text-rendering: auto;
    color: initial;
    letter-spacing: normal;
    word-spacing: normal;
    text-transform: none;
    text-indent: 0px;
    text-shadow: none;
    display: inline-block;
    text-align: start;
    margin: 0em 0em 0em 0em;
    font: 13.3333px Arial;
}
user agent stylesheetinput,
textarea,
keygen,
select,
button,
meter,
progress {
    -webkit-writing-mode: horizontal-tb;
}
user agent stylesheetbutton {
    -webkit-appearance: button;
}
.btTxt submit {
    border: 3px solid #fff;
    color: #fff;
}
.btTxt submit {
    border: none;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: none;
    cursor: pointer;
    padding: 25px 80px;
    display: inline-block;
    margin: 15px 30px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    outline: none;
    position: relative;
    -webkit-transition: all 0.3s;
    -moz-transition: all 0.3s;
    transition: all 0.3s;
}
*,
*:after,
*:before {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
#button {

  /*Reset*/
  display: inline-block;
  outline: none;
  background-color: transparent;

  /*Some fancy stuff*/
  padding: 0 20px;
  line-height: 200%;
  border: 1px solid silver;

  /*Magic*/
  background-image: linear-gradient(PaleVioletRed, PaleVioletRed 50%, Sienna 50%, Sienna);
  background-size: 100% 200%;
  -webkit-transition: background-position .3s;
  transition: background-position .3s;
}
#button:hover {
  background-position: 0 -100%;
}