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

时间:2015-08-26 13:32:26

标签: html css css3

当我使用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;
}

2 个答案:

答案 0 :(得分:0)

您的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-color州的:hover

如果你松开背景图片,它将起作用:

&#13;
&#13;
.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;
}
&#13;
<div role="button" class="ico-btn red"><span class="icon-sad"></span>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

<security:intercept-url pattern="/logged/**" access="ROLE_USER" /> 中删除以下行,因为它们会覆盖悬停状态:

ico-btn.red