Javascript 合并两类div
我正在尝试将两个div类合并在一起,这样它就可以工作了。林克:还有这个。我正试图将这些东西结合在一起,但我做不到。我怎么能做到呢?唯一有效的方法是抖动图像,我希望两者都能一起工作。我现在将.overlay从link one添加到auto style3中 css代码是Javascript 合并两类div,javascript,html,css,Javascript,Html,Css,我正在尝试将两个div类合并在一起,这样它就可以工作了。林克:还有这个。我正试图将这些东西结合在一起,但我做不到。我怎么能做到呢?唯一有效的方法是抖动图像,我希望两者都能一起工作。我现在将.overlay从link one添加到auto style3中 css代码是 img:hover { animation: shake 0.2s; animation-iteration-count: infinite; } @keyframes shake { 0% { transform:
img:hover {
animation: shake 0.2s;
animation-iteration-count: infinite;
}
@keyframes shake {
0% { transform: translate(1px, 1px) rotate(0deg); }
10% { transform: translate(-1px, -2px) rotate(-1deg); }
20% { transform: translate(-3px, 0px) rotate(1deg); }
30% { transform: translate(3px, 2px) rotate(0deg); }
40% { transform: translate(1px, -1px) rotate(1deg); }
50% { transform: translate(-1px, 2px) rotate(-1deg); }
60% { transform: translate(-3px, 1px) rotate(0deg); }
70% { transform: translate(3px, 1px) rotate(-1deg); }
80% { transform: translate(-1px, -1px) rotate(1deg); }
90% { transform: translate(1px, 2px) rotate(0deg); }
100% { transform: translate(1px, -2px) rotate(-1deg); }
}
.auto-style3 {
margin-top: 0px;
position: absolute;
bottom: 0;
background: rgb(0, 0, 0);
background: rgba(0, 0, 0, 0.5); /* Black see-through */
color: #f1f1f1;
width: 100%;
transition: .5s ease;
opacity:0;
color: white;
font-size: 20px;
padding: 20px;
text-align: center;
}
.auto-style4 {
background-color: #FF0000;
}
* {box-sizing: border-box;}
.container {
position: relative;
width: 50%;
max-width: 300px;
}
.image {
display: block;
width: 100%;
height: auto;
}
.container:hover .overlay {
opacity: 1;
}
我的代码是
<div class="container" >
<img src="avatar.jpg" alt="Avatar" width="278" height="262" class="style3" >
<div class="auto-style3">
Avatar is ON
</div>
</div>
《阿凡达》上映了
我直接复制/粘贴了两个源代码,然后更改了下面代码段中CSS的第一行(img:hover
->.container:hover
)
.container:悬停{
/*启动抖动动画并使动画持续0.5秒*/
动画:抖动0.5s;
/*动画完成后,重新开始*/
动画迭代次数:无限;
}
@关键帧抖动{
0%{变换:平移(1px,1px)旋转(0deg);}
10%{变换:平移(-1px,-2px)旋转(-1deg);}
20%{变换:平移(-3px,0px)旋转(1deg);}
30%{变换:平移(3px,2px)旋转(0deg);}
40%{变换:平移(1px,-1px)旋转(1deg);}
50%{变换:平移(-1px,2px)旋转(-1deg);}
60%{变换:平移(-3px,1px)旋转(0度);}
70%{变换:平移(3px,1px)旋转(-1deg);}
80%{变换:平移(-1px,-1px)旋转(1deg);}
90%{变换:平移(1px,2px)旋转(0度);}
100%{变换:平移(1px,-2px)旋转(-1deg);}
}
.集装箱{
位置:相对位置;
宽度:100%;
最大宽度:400px;
}
.形象{
显示:块;
宽度:100%;
高度:自动;
}
.覆盖{
位置:绝对位置;
排名:0;
底部:0;
左:0;
右:0;
身高:100%;
宽度:100%;
不透明度:0;
过渡:放松;
背景色:红色;
}
.container:悬停。覆盖{
不透明度:1;
}
.图标{
颜色:白色;
字体大小:100px;
位置:绝对位置;
最高:50%;
左:50%;
转换:翻译(-50%,-50%);
-ms转换:翻译(-50%,-50%);
文本对齐:居中;
}
.fa用户:悬停{
颜色:#eee;
}
当您将它们添加到一起时,您尝试了什么?我希望两者都看起来像是震动和黑色消息。唯一的问题似乎是震动。我想我需要这样做才能让它工作div class=“container”,“overlay”你做了什么?你能把它加在柱子上吗?只有震动。我没能同时完成这两项工作。我想让它们以相同的形象工作