- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
对不起,如果我搞砸了标题。我不太确定如何正确描述我的情况。我还是个初学者。
无论如何,我正在尝试在图像上创建一个简单的悬停效果,该效果将显示独特数组中的一个词,将其更改为另一个并每隔 .12s
重复一次 - 一种闪烁效果。
我一开始会有 8 张图片,这意味着我必须创建 8 个不同的数组。
问题是,为了让一切正常,我必须为每个单独的图像/独特的类乘以相同的函数,这对我来说似乎有点困惑,即使它有效。
这是两个容器的小例子 - 将鼠标悬停在灰色区域:
$(window).on("load", function() {
var LP1 = [
'ui',
'ux',
'webdesign',
'logo',
'responsive',
'personal'
], i = 0;
setInterval(function(){
$('.left-title').fadeOut(0, function(){
$(this).html(LP1[i=(i+1)%LP1.length]).fadeIn(0);
});
}, 120);
var LP2 = [
'cover',
'art',
'music',
'print',
'personal'
], i = 0;
setInterval(function(){
$('.right-title').fadeOut(0, function(){
$(this).html(LP2[i=(i+1)%LP2.length]).fadeIn(0);
});
}, 120);
});
* {
margin: 0;
padding: 0;
}
body {
height: 100%;
width: 100%;
}
.wrap-fixed-real {
width: calc(100% - 32px);
height: calc(100% - 32px);
position: fixed;
top: 16px;
left: 16px;
z-index: 1;
}
.left {
top: 0;
position: absolute;
left: 0px;
height: 100%;
width: calc(50% - 8px);
background-color: #292929;
}
.right{
top: 0px;
position: absolute;
right: 0px;
height: 100%;
width: calc(50% - 8px);
background-color: #292929;
}
.dimming {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
z-index: 2;
background-color: #000000;
transition: opacity .24s 0s cubic-bezier(.64,0,.36,1);
}
.left-title {
position: absolute;
display: block;
width: calc(100% - 32px);
top: 50%;
transform: translateY(-50%);
left: 16px;
z-index: 3;
opacity: 0;
font-family: 'Roboto', sans-serif;
font-weight: normal;
font-size: 32px;
text-align: center;
line-height: 48px;
color: #ffffff;
mix-blend-mode: difference;
transition: opacity .24s 0s cubic-bezier(.64,0,.36,1);
}
.left:hover .dimming {
opacity: .4;
}
.left:hover .left-title {
opacity: 1;
}
.right-title {
position: absolute;
display: block;
width: calc(100% - 32px);
top: 50%;
transform: translateY(-50%);
left: 16px;
z-index: 3;
opacity: 0;
font-family: 'Roboto', sans-serif;
font-weight: normal;
font-size: 32px;
text-align: center;
line-height: 48px;
color: #ffffff;
mix-blend-mode: difference;
transition: opacity .24s 0s cubic-bezier(.64,0,.36,1);
}
.right:hover .dimming {
opacity: .4;
}
.right:hover .right-title {
opacity: 1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<div class="wrap-fixed-real">
<div class="left">
<div class="left-title">LP1</div>
<div class="dimming"></div>
</div>
<div class="right">
<div class="right-title">LP2</div>
<div class="dimming"></div>
</div>
</div>
</body>
对不起,乱七八糟的代码。如果涉及到 css,我想我可以创建 8 个不同的子类和 1 个将共享相同样式的唯一子类,但我不知道如何强制单个函数为每个图像/唯一类使用不同的数组。我在互联网上做了一些研究,但找不到答案。也许我只是在谷歌中使用了错误的关键字,所以如果有人能指出我正确的方向,那就太好了。或者也许只通过乘以一个函数就可以创建我想要的东西?我不确定。
总结:我希望每个唯一的数组都与唯一的类和单个函数连接,这将使“闪烁的铭文”效果发生。
还有一件事我不太确定。每 .12s
更改文本的效果将同时播放 8 个不同的图像。它会减慢我的网站速度吗?也许另外我应该在开始时隐藏这个效果,而不是仅仅将不透明度设置为 0?
最佳答案
您可以为此创建一个小的 jQuery 插件:
$.fn.flashWith = function (LP, delay) {
setInterval(function(){
this.fadeOut(0, function(){
// cycle the given array as you get the first text
$(this).text(LP.shift(LP.push(LP[0]))).fadeIn(0);
});
}.bind(this), delay);
return this;
};
$(function() {
$('.left-title').flashWith([
'ui',
'ux',
'webdesign',
'logo',
'responsive',
'personal'
], 120);
$('.right-title').flashWith([
'cover',
'art',
'music',
'print',
'personal'
], 120);
});
* {
margin: 0;
padding: 0;
}
body {
height: 100%;
width: 100%;
}
.wrap-fixed-real {
width: calc(100% - 32px);
height: calc(100% - 32px);
position: fixed;
top: 16px;
left: 16px;
z-index: 1;
}
.left {
top: 0;
position: absolute;
left: 0px;
height: 100%;
width: calc(50% - 8px);
background-color: #292929;
}
.right{
top: 0px;
position: absolute;
right: 0px;
height: 100%;
width: calc(50% - 8px);
background-color: #292929;
}
.dimming {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
z-index: 2;
background-color: #000000;
transition: opacity .24s 0s cubic-bezier(.64,0,.36,1);
}
.left-title {
position: absolute;
display: block;
width: calc(100% - 32px);
top: 50%;
transform: translateY(-50%);
left: 16px;
z-index: 3;
opacity: 0;
font-family: 'Roboto', sans-serif;
font-weight: normal;
font-size: 32px;
text-align: center;
line-height: 48px;
color: #ffffff;
mix-blend-mode: difference;
transition: opacity .24s 0s cubic-bezier(.64,0,.36,1);
}
.left:hover .dimming {
opacity: .4;
}
.left:hover .left-title {
opacity: 1;
}
.right-title {
position: absolute;
display: block;
width: calc(100% - 32px);
top: 50%;
transform: translateY(-50%);
left: 16px;
z-index: 3;
opacity: 0;
font-family: 'Roboto', sans-serif;
font-weight: normal;
font-size: 32px;
text-align: center;
line-height: 48px;
color: #ffffff;
mix-blend-mode: difference;
transition: opacity .24s 0s cubic-bezier(.64,0,.36,1);
}
.right:hover .dimming {
opacity: .4;
}
.right:hover .right-title {
opacity: 1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<div class="wrap-fixed-real">
<div class="left">
<div class="left-title">LP1</div>
<div class="dimming"></div>
</div>
<div class="right">
<div class="right-title">LP2</div>
<div class="dimming"></div>
</div>
</div>
</body>
关于jquery - 相同的函数将为每个独特的类使用不同的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46254824/
我正在尝试创建一个包含 int[][] 项的数组 即 int version0Indexes[][4] = { {1,2,3,4}, {5,6,7,8} }; int version1Indexes[
我有一个整数数组: private int array[]; 如果我还有一个名为 add 的方法,那么以下有什么区别: public void add(int value) { array[va
当您尝试在 JavaScript 中将一个数组添加到另一个数组时,它会将其转换为一个字符串。通常,当以另一种语言执行此操作时,列表会合并。 JavaScript [1, 2] + [3, 4] = "
根据我正在阅读的教程,如果您想创建一个包含 5 列和 3 行的表格来表示这样的数据... 45 4 34 99 56 3 23 99 43 2 1 1 0 43 67 ...它说你可以使用下
我通常使用 python 编写脚本/程序,但最近开始使用 JavaScript 进行编程,并且在使用数组时遇到了一些问题。 在 python 中,当我创建一个数组并使用 for x in y 时,我得
我有一个这样的数组: temp = [ 'data1', ['data1_a','data1_b'], ['data2_a','data2_b','data2_c'] ]; // 我想使用 toStr
rent_property (table name) id fullName propertyName 1 A House Name1 2 B
这个问题在这里已经有了答案: 关闭13年前。 Possible Duplicate: In C arrays why is this true? a[5] == 5[a] array[index] 和
使用 Excel 2013。经过多年的寻找和适应,我的第一篇文章。 我正在尝试将当前 App 用户(即“John Smith”)与他的电子邮件地址“jsmith@work.com”进行匹配。 使用两个
当仅在一个边距上操作时,apply 似乎不会重新组装 3D 数组。考虑: arr 1),但对我来说仍然很奇怪,如果一个函数返回一个具有尺寸的对象,那么它们基本上会被忽略。 最佳答案 这是一个不太理
我有一个包含 GPS 坐标的 MySQL 数据库。这是我检索坐标的部分 PHP 代码; $sql = "SELECT lat, lon FROM gps_data"; $stmt=$db->query
我需要找到一种方法来执行这个操作,我有一个形状数组 [批量大小, 150, 1] 代表 batch_size 整数序列,每个序列有 150 个元素长,但在每个序列中都有很多添加的零,以使所有序列具有相
我必须通过 url 中的 json 获取文本。 层次结构如下: 对象>数组>对象>数组>对象。 我想用这段代码获取文本。但是我收到错误 :org.json.JSONException: No valu
enter code here- (void)viewDidLoad { NSMutableArray *imageViewArray= [[NSMutableArray alloc] init];
知道如何对二维字符串数组执行修剪操作,例如使用 Java 流 API 进行 3x3 并将其收集回相同维度的 3x3 数组? 重点是避免使用显式的 for 循环。 当前的解决方案只是简单地执行一个 fo
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我有来自 ASP.NET Web 服务的以下 XML 输出: 1710 1711 1712 1713
如果我有一个对象todo作为您状态的一部分,并且该对象包含数组列表,则列表内部有对象,在这些对象内部还有另一个数组listItems。如何更新数组 listItems 中 id 为“poi098”的对
我想将最大长度为 8 的 bool 数组打包成一个字节,通过网络发送它,然后将其解压回 bool 数组。已经在这里尝试了一些解决方案,但没有用。我正在使用单声道。 我制作了 BitArray,然后尝试
我们的数据库中有这个字段指示一周中的每一天的真/假标志,如下所示:'1111110' 我需要将此值转换为 boolean 数组。 为此,我编写了以下代码: char[] freqs = weekday
我是一名优秀的程序员,十分优秀!