在循环Javascript中更改悬停样式
在循环Javascript中更改悬停样式,javascript,html,css,loops,styles,Javascript,Html,Css,Loops,Styles,函数关闭字节id(el,id){ 而(el.id!=id){ el=el.parentNode; 如果(!el){ 返回null; } } 返回el; } var元素=document.getElementsByClassName('btn fa input'); 对于(变量i=0;i
函数关闭字节id(el,id){
而(el.id!=id){
el=el.parentNode;
如果(!el){
返回null;
}
}
返回el;
}
var元素=document.getElementsByClassName('btn fa input');
对于(变量i=0;i
.btn幻灯片标签:悬停。底部标签{
裕度:-100px 0 10px;
}
下载:1546次
1.2MB拉链
下载:1546次
1.2MB拉链
如果我可以建议一个没有一点javascript的纯CSS解决方案,下面是如何做到的:
我在父元素上玩了相对位置。btn滑动子元素的标签
和绝对位置
来定位它们,不管按钮有多大
CSS:
body {
margin-top: 100px;
text-align: center;
}
.btn-slides-labels {
display: inline-block;
position: relative;
}
.top-label, .bottom-label {
background: #222;
display: block;
height: 40px;
width: 100%;
text-align: center;
font: 12px/45px Helvetica, Verdana, sans-serif;
color: #fff;
position: absolute;
z-index: -1;
box-sizing : border-box;
}
.bottom-label {
-webkit-border-radius: 10px 10px 0px 0px;
-moz-border-radius: 10px 10px 0px 0px;
border-radius: 10px 10px 0px 0px;
-webkit-transition: top 0.5s ease;
-moz-transition: top 0.5s ease;
-o-transition: top 0.5s ease;
-ms-transition: top 0.5s ease;
transition: top 0.5s ease;
line-height: 35px;
top: 10px;
}
.top-label {
-webkit-border-radius: 0px 0px 10px 10px;
-moz-border-radius: 0px 0px 10px 10px;
border-radius: 0px 0px 10px 10px;
-webkit-transition: bottom 0.5s ease;
-moz-transition: bottom 0.5s ease;
-o-transition: bottom 0.5s ease;
-ms-transition: bottom 0.5s ease;
transition: bottom 0.5s ease;
line-height: 45px;
bottom:10px;
}
/* HOVER */
.btn-slides-labels:hover .bottom-label {
top: -25px;
}
.btn-slides-labels:hover .top-label {
bottom: -25px;
}
.btn {
text-align: center;
background: #dd3333;
color: #f7f7f7;
font-size: 023px;
border-radius: 005px;
padding: 15px 35px;
box-shadow: 0 -003px rgba(0, 0, 0, 0.14) inset;
display: inline-block;
text-transform: uppercase;
text-decoration: none;
margin: 10px 0px;
transition: all 0.2s linear 0s;
-moz-transition: all 0.2s linear 0s;
-webkit-transition: all 0.2s linear 0s;
-o-transition: all 0.2s linear 0s;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-o-border-radius: 5px;
box-shadow: 0 -4px rgba(0, 0, 0, 0.14) inset;
-moz-box-shadow: 0 -4px rgba(0, 0, 0, 0.14) inset;
-webkit-box-shadow: 0 -4px rgba(0, 0, 0, 0.14) inset;
-o-box-shadow: 0 -4px rgba(0, 0, 0, 0.14) inset;
letter-spacing: 1.5px;
border: none;
cursor: pointer;
}
.btn:hover {
background: #2ecc71;
}