html - 触摸设备的 CSS 过渡悬停效果

标签 html css

当我使用 CSS 点击按钮时,我试图获得悬停/触摸效果。我已经使用下面的 CSS 转换来更改背景,但它似乎不起作用:

https://jsfiddle.net/s3vbgos7/

HTML

<div role="button" class="ico-btn red"></div>

CSS

.ico-btn {
    -webkit-user-select: none; margin-right: 0px;
    -webkit-box-shadow: rgba(0, 0, 0, 0.298039) 0px 2px 10px 0px, rgba(0, 0, 0, 0.0980392) 0px 0px 1px 0px, rgba(255, 255, 255, 0.247059) 0px 1px 0px 0px inset, rgba(0, 0, 0, 0.14902) 0px -1px 0px 0px inset;
    -webkit-font-smoothing: antialiased;
    border-bottom-left-radius: 25%;
    border-bottom-right-radius: 25%;
    border-top-left-radius: 25%;
    border-top-right-radius: 25%;
    box-shadow: rgba(0, 0, 0, 0.298039) 0px 2px 10px 0px, rgba(0, 0, 0, 0.0980392) 0px 0px 1px 0px, rgba(255, 255, 255, 0.247059) 0px 1px 0px 0px inset, rgba(0, 0, 0, 0.14902) 0px -1px 0px 0px inset;
    cursor: pointer;
    display: block;
    font-family: Roboto, Arial, sans-serif;
    font-size: 140px;
    font-weight: normal;
    height: 177px; /*167px;*/
    line-height: 150px;
    min-width: 0px;
    padding: 40px 0 0 0; /*30*/
    text-align: center;
    white-space: nowrap;
    width: 220px;/*200*/
    z-index: 2;
    margin: 0 auto;
    color:#fff;
}

.ico-btn.red { background-color: rgb(219, 68, 55);
    background-image: -moz-linear-gradient( 90deg, rgb(170,34,23) 0%, rgb(170,34,23) 0%, rgb(195,51,39) 22%, rgb(219,68,55) 100%);
    background-image: -webkit-linear-gradient( 90deg, rgb(170,34,23) 0%, rgb(170,34,23) 0%, rgb(195,51,39) 22%, rgb(219,68,55) 100%);
    background-image: -ms-linear-gradient( 90deg, rgb(170,34,23) 0%, rgb(170,34,23) 0%, rgb(195,51,39) 22%, rgb(219,68,55) 100%);
    border-bottom-color:#ab2318;
    border-bottom-left-radius: 25%;
    border-bottom-right-radius: 25%;
    border-bottom-style: solid;
    border-bottom-width: 1px;
    border-left-color: rgb(0, 0, 0);
    border-left-style: none;
    border-left-width: 0px;
    border-right-color: rgb(0, 0, 0);
    border-right-style: none;
    border-right-width: 0px;
    border-top-color:#ef675c;
    border-top-left-radius: 25%;
    border-top-right-radius: 25%;
    border-top-style: solid;
    border-top-width: 2px;
    transition: all .1s linear;
}
.ico-btn.red:hover {
    background-color: #D05944;
    -webkit-transition: background-color .25s ease-in-out;
    -moz-transition: background-color .25s ease-in-out;
    -o-transition: background-color .25s ease-in-out;
    transition: background-color .25s ease-in-out;
}

最佳答案

你的 背景图像:-moz-linear-gradient( 90deg, rgb(170,34,23) 0%, rgb(170,34,23) 0%, rgb(195,51,39) 22%, rgb(219,68,55) 100%); 覆盖 :hover 状态下的 background-color

如果你松开背景图像,它会起作用:

.ico-btn {
    -webkit-user-select: none; margin-right: 0px;
    -webkit-box-shadow: rgba(0, 0, 0, 0.298039) 0px 2px 10px 0px, rgba(0, 0, 0, 0.0980392) 0px 0px 1px 0px, rgba(255, 255, 255, 0.247059) 0px 1px 0px 0px inset, rgba(0, 0, 0, 0.14902) 0px -1px 0px 0px inset;
    -webkit-font-smoothing: antialiased;
    border-bottom-left-radius: 25%;
    border-bottom-right-radius: 25%;
    border-top-left-radius: 25%;
    border-top-right-radius: 25%;
    box-shadow: rgba(0, 0, 0, 0.298039) 0px 2px 10px 0px, rgba(0, 0, 0, 0.0980392) 0px 0px 1px 0px, rgba(255, 255, 255, 0.247059) 0px 1px 0px 0px inset, rgba(0, 0, 0, 0.14902) 0px -1px 0px 0px inset;
    cursor: pointer;
    display: block;
    font-family: Roboto, Arial, sans-serif;
    font-size: 140px;
    font-weight: normal;
    height: 177px; /*167px;*/
    line-height: 150px;
    min-width: 0px;
    padding: 40px 0 0 0; /*30*/
    text-align: center;
    white-space: nowrap;
    width: 220px;/*200*/
    z-index: 2;
    margin: 0 auto;
    color:#fff;
}

.ico-btn.red { background-color: rgb(219, 68, 55);
    border-bottom-color:#ab2318;
    border-bottom-left-radius: 25%;
    border-bottom-right-radius: 25%;
    border-bottom-style: solid;
    border-bottom-width: 1px;
    border-left-color: rgb(0, 0, 0);
    border-left-style: none;
    border-left-width: 0px;
    border-right-color: rgb(0, 0, 0);
    border-right-style: none;
    border-right-width: 0px;
    border-top-color:#ef675c;
    border-top-left-radius: 25%;
    border-top-right-radius: 25%;
    border-top-style: solid;
    border-top-width: 2px;
    transition: all .1s linear;
}
.ico-btn.red:hover {
	background-color: #D05944;
	-webkit-transition: background-color .25s ease-in-out;
	-moz-transition: background-color .25s ease-in-out;
	-o-transition: background-color .25s ease-in-out;
	transition: background-color .25s ease-in-out;
}
<div role="button" class="ico-btn red"><span class="icon-sad"></span>
</div>

关于html - 触摸设备的 CSS 过渡悬停效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32228098/

相关文章:

html - 图表的语义表示

html - 文本未包装在容器中

jquery - CSS显示:inline animation not working using jquery addClass

html - 有多个表格,需要选择特定行并通过CSS更改背景颜色

php - 如何使用ajax上传图片并预览

php - 无法在响应式表格布局中显示表格标题

html - 到达页面末尾时将 DIV 放置在新列中

javascript - 过滤/查找 .eq() 两个不同值的元素

html - 使用 CSS 设计多边形形状

javascript - 这段代码有什么问题(响应式 html-css-js)?