作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的网站上有 fa 图标,图标后面有小背景。当我添加“transform: scale(1.2);”使悬停时图标变大的代码,背景也变大。如何解决这个问题? :/
这是整个代码:
#snav {
position: fixed;
top: 28%;
z-index: 9999;
font-size: 18px;
font-family: 'Open Sans', sans-serif;
}
#snav ul { list-style: none; }
#snav * {
margin: 0;
padding: 0;
outline: 0;
transition: all .5s ease;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
-o-transition: all .5s ease;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#snav li a {
text-decoration: none;
color: #fafaf9;
display: block;
position: relative;
}
#snav .fa {
vertical-align: middle;
font-size: 18px;
width: 35px;
height: 35px;
line-height: 35px;
text-align: center;
position: relative;
z-index: 4;
}
#snav li span {
font-size: 15px;
vertical-align: middle;
height: 35px;
line-height: 35px;
width: auto;
white-space: nowrap;
overflow: hidden;
display: block;
padding: 0 15px;
position: absolute;
top: 0;
visibility: hidden;
z-index: 3;
}
#snav li a:hover .fa { transform: scale(1.2); }
.snav li a:hover .fa {
display: inline-block;
vertical-align: middle;
-webkit-transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px transparent;
position: relative;
padding-right: 2.2em;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
}
#snav li a:hover span { visibility: visible; }
#snav li span { background-color: #555; }
/* icons color and background before hover */
#snav li .fa {
background-color: #EEE;
color: #555;
}
/* icons hover color */
#snav li a:hover .fa { color: #fafaf9; }
/* repeated colors from 1 to 10 each hover color repeated after 10 menu items */
#snav li:nth-child(10n+1) span,
#snav li:nth-child(10n+1) a:hover .fa { background-color: #3b2551; }
#snav li:nth-child(10n+2) span,
#snav li:nth-child(10n+2) a:hover .fa { background-color: #4EC5DB; }
#snav li:nth-child(10n+3) span,
#snav li:nth-child(10n+3) a:hover .fa { background-color: #3DC25D; }
#snav li:nth-child(10n+4) span,
#snav li:nth-child(10n+4) a:hover .fa { background-color: #99BE24; }
#snav li:nth-child(10n+5) span,
#snav li:nth-child(10n+5) a:hover .fa { background-color: #38c; }
#snav li:nth-child(10n+6) span,
#snav li:nth-child(10n+6) a:hover .fa { background-color: #3b5997; }
#snav li:nth-child(10n+7) span,
#snav li:nth-child(10n+7) a:hover .fa { background-color: #6a453a; }
#snav li:nth-child(10n+8) span,
#snav li:nth-child(10n+8) a:hover .fa { background-color: #0bbff2; }
#snav.en {
left: 0;
text-align: left;
}
#snav.en li span { left: -100px; }
#snav.en li a:hover span { left: 35px; }
最佳答案
而不是使用:
变换:缩放(1,2);
尝试更改图标的字体大小。
字体大小:10px;
转换可能会干扰其他代码。
如果有帮助,请投票!
关于html - 成长只是 "fa fa"图标没有背景webkit-transform css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42308077/
我在一个最大高度为 80 的 div 内的表单中有一个 textarea。我的问题是当 textarea 中的文本太长时,textarea 应该从它的初始高度增长到 cb-input div 的最大高
我是编程初学者。最近,我编写了一个程序来从字符串日期中获取日、月、年并将其转换为 int 并分配给数组的元素。但是 VS 在编译时返回一个错误,我不太明白。请帮我解释一下!提前致谢!我的程序 usin
我最近发现了以下文本进度样式的方法,想知道是否有一种变通方法可以从中心增加元素宽度,这样文本也会从中心而不是从左侧填充。 body { background-color: black; } p {
我是一名优秀的程序员,十分优秀!