css 悬停动画在 icomoon 中不起作用
css hover animate doasn't work in icomoon
我的菜单带有 css3 悬停动画(toTopFromBottom
)。现在我需要将 fontawesome 图标更改为 icomoon 图标并添加此效果:
HTML:
<div id="top-bar" class="top-bar">
<div class="container">
<div class="col-md-12">
<div class="row">
<div class="social-icons social-icons-colored-hover">
<ul>
<li class="social-facebook"><a href="#"><i class="icon-mug"></i></a></li>
<li class="social-twitter"><a href="#"><i class="icon-rocket"></i></a></li>
<li class="social-google"><a href="#"><i class="icon-paint-format"></i></a></li>
<li class="social-vimeo"><a href="#"><i class="icon-pencil"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
CSS:
#top-bar .social-icons {
float: right;
height: 100%;
overflow: hidden;
}
#top-bar .social-icons li,
#top-bar .social-icons li a {
float: left;
list-style: outside none none;
}
#top-bar .social-icons li a {
border-radius: 0px;
border-right: 1px solid rgba(180, 180, 180, 0.2);
font-size: 15px;
height: 40px;
line-height: 40px;
text-align: center;
width: 35px;
overflow: hidden;
margin: 0;
}
#top-bar .social-icons li:first-child a {
border-left: 1px solid rgba(180, 180, 180, 0.2);
}
.social-icons ul {
padding: 0;
}
.text-center.social-icons ul {
display: inline-block;
}
.social-icons li {
float: left;
list-style: none;
}
.social-icons li a {
float: left;
height: 32px;
width: 32px;
line-height: 32px;
font-size: 16px;
text-align: center;
margin: 0 8px 8px 0;
border-radius: 4px;
border: 0;
background: transparent;
color: #565b73;
overflow: hidden;
}
/*Colored*/
.social-icons.social-icons-colored a,
.social-icons.social-icons-colored-hover a:hover {
color: #fff;
border: 0;
}
.social-icons.social-icons-colored .social-facebook a,
.social-icons.social-icons-colored-hover .social-facebook a:hover {
background-color: #5d82d1;
}
.social-icons.social-icons-colored .social-twitter a,
.social-icons.social-icons-colored-hover .social-twitter a:hover {
background-color: #40bff5;
}
.social-icons.social-icons-colored .social-vimeo a,
.social-icons.social-icons-colored-hover .social-vimeo a:hover {
background-color: #35c6ea;
}
.social-icons.social-icons-colored .social-google a,
.social-icons.social-icons-colored-hover .social-google a:hover {
background-color: #eb5e4c;
}
/* Border */
.social-icons.social-icons-border li a {
border: 1px solid #eee;
background: transparent;
color: #333;
}
.social-icons:not(.social-icons-colored):not(.social-icons-colored-hover)
li
a:hover {
background-color: #eee;
}
.social-icons li:hover i {
-webkit-animation: toTopFromBottom 0.3s forwards;
-moz-animation: toTopFromBottom 0.3s forwards;
animation: toTopFromBottom 0.3s forwards;
}
@-webkit-keyframes toTopFromBottom {
49% {
-webkit-transform: translateY(-100%);
}
50% {
opacity: 0;
-webkit-transform: translateY(100%);
}
51% {
opacity: 1;
}
}
@-moz-keyframes toTopFromBottom {
49% {
-moz-transform: translateY(-100%);
}
50% {
opacity: 0;
-moz-transform: translateY(100%);
}
51% {
opacity: 1;
}
}
@keyframes toTopFromBottom {
49% {
transform: translateY(-100%);
}
50% {
opacity: 0;
transform: translateY(100%);
}
51% {
opacity: 1;
}
}
但实际上 css 效果不适用于 icomoon。
尝试display: inline-block
[class^="icon-"],
[class*=" icon-"] {
display: inline-block
font-family: "icomoon";
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
您需要将 display:inline-block;
添加到 [class^="icon-"],[class*=" icon-"]
选择器
此处的工作演示:https://jsfiddle.net/hb874txq/
我的菜单带有 css3 悬停动画(toTopFromBottom
)。现在我需要将 fontawesome 图标更改为 icomoon 图标并添加此效果:
HTML:
<div id="top-bar" class="top-bar">
<div class="container">
<div class="col-md-12">
<div class="row">
<div class="social-icons social-icons-colored-hover">
<ul>
<li class="social-facebook"><a href="#"><i class="icon-mug"></i></a></li>
<li class="social-twitter"><a href="#"><i class="icon-rocket"></i></a></li>
<li class="social-google"><a href="#"><i class="icon-paint-format"></i></a></li>
<li class="social-vimeo"><a href="#"><i class="icon-pencil"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
CSS:
#top-bar .social-icons {
float: right;
height: 100%;
overflow: hidden;
}
#top-bar .social-icons li,
#top-bar .social-icons li a {
float: left;
list-style: outside none none;
}
#top-bar .social-icons li a {
border-radius: 0px;
border-right: 1px solid rgba(180, 180, 180, 0.2);
font-size: 15px;
height: 40px;
line-height: 40px;
text-align: center;
width: 35px;
overflow: hidden;
margin: 0;
}
#top-bar .social-icons li:first-child a {
border-left: 1px solid rgba(180, 180, 180, 0.2);
}
.social-icons ul {
padding: 0;
}
.text-center.social-icons ul {
display: inline-block;
}
.social-icons li {
float: left;
list-style: none;
}
.social-icons li a {
float: left;
height: 32px;
width: 32px;
line-height: 32px;
font-size: 16px;
text-align: center;
margin: 0 8px 8px 0;
border-radius: 4px;
border: 0;
background: transparent;
color: #565b73;
overflow: hidden;
}
/*Colored*/
.social-icons.social-icons-colored a,
.social-icons.social-icons-colored-hover a:hover {
color: #fff;
border: 0;
}
.social-icons.social-icons-colored .social-facebook a,
.social-icons.social-icons-colored-hover .social-facebook a:hover {
background-color: #5d82d1;
}
.social-icons.social-icons-colored .social-twitter a,
.social-icons.social-icons-colored-hover .social-twitter a:hover {
background-color: #40bff5;
}
.social-icons.social-icons-colored .social-vimeo a,
.social-icons.social-icons-colored-hover .social-vimeo a:hover {
background-color: #35c6ea;
}
.social-icons.social-icons-colored .social-google a,
.social-icons.social-icons-colored-hover .social-google a:hover {
background-color: #eb5e4c;
}
/* Border */
.social-icons.social-icons-border li a {
border: 1px solid #eee;
background: transparent;
color: #333;
}
.social-icons:not(.social-icons-colored):not(.social-icons-colored-hover)
li
a:hover {
background-color: #eee;
}
.social-icons li:hover i {
-webkit-animation: toTopFromBottom 0.3s forwards;
-moz-animation: toTopFromBottom 0.3s forwards;
animation: toTopFromBottom 0.3s forwards;
}
@-webkit-keyframes toTopFromBottom {
49% {
-webkit-transform: translateY(-100%);
}
50% {
opacity: 0;
-webkit-transform: translateY(100%);
}
51% {
opacity: 1;
}
}
@-moz-keyframes toTopFromBottom {
49% {
-moz-transform: translateY(-100%);
}
50% {
opacity: 0;
-moz-transform: translateY(100%);
}
51% {
opacity: 1;
}
}
@keyframes toTopFromBottom {
49% {
transform: translateY(-100%);
}
50% {
opacity: 0;
transform: translateY(100%);
}
51% {
opacity: 1;
}
}
但实际上 css 效果不适用于 icomoon。
尝试display: inline-block
[class^="icon-"],
[class*=" icon-"] {
display: inline-block
font-family: "icomoon";
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
您需要将 display:inline-block;
添加到 [class^="icon-"],[class*=" icon-"]
选择器
此处的工作演示:https://jsfiddle.net/hb874txq/