gpt4 book ai didi

html - 将一个 block 替换为另一个

转载 作者:太空宇宙 更新时间:2023-11-04 06:41:35 25 4
gpt4 key购买 nike

这是响应式版本,但我只需要在几秒钟后将文本 block 更改为另一个文本 block

enter image description here

我有 4 个 div 文本 block 。我需要在响应版本中看到一个 block ,它会在几秒钟后被另一个文本 block 替换。你知道我该怎么做吗?请帮助..

这是我的 HTML:

  <div class="div-wrap">
<div class="div-wrap-txt">
<div class="div-txt" style="padding-right: 35px;">
<p class="label">Connt</p>
<p style="color: #6B7684;">shoulders, turn<br> on it and connect application <br>with device.</p>
</div>
<div class="div-txt" style="padding-right: 35px; margin-top: 50px;">
<p class="label">Calib</p>
<p style="color: #6B7684;">calibration to help device remember your upright and slouch positions.</p>
</div>
</div>
<div class="div-img">
</div>
<div class="div-wrap-txt">
<div class="div-txt" style="text-align: left; padding-left: 25px;">
<p class="label">Train</p>
<p style="color: #6B7684;">posture anytime you want, <br>set up daily goal to improve gradually <br>your posture.</p>
</div>
<div class="div-txt" style="text-align: left; padding-left: 25px; margin-top: 50px;">
<p class="label">Anale</p>
<p style="color: #6B7684;">Statistics let track the <br>progress you’ve made from first <br>training to the last.</p>
</div>
</div>
</div>

CSS:

  .div-img img {
position: absolute;
top: 0;
left: 50%;
display: block;
transform: translateX(-50%);
opacity: 0;
animation-duration: calc(var(--time) * 1s);
animation-iteration-count: infinite;
animation-name: fade;
}

.div-img img:nth-child(1) {
animation-delay: 0s;
}

.div-img img:nth-child(2) {
animation-delay: calc(var(--time) / 8 * 1s);
}

.div-img img:nth-child(3) {
animation-delay: calc(var(--time) / 4 * 1s);
}

.div-img img:nth-child(4) {
animation-delay: calc(var(--time) / 2.66 * 1s);
}

.div-img img:nth-child(5) {
animation-delay: calc(var(--time) / 2 * 1s);
}

.div-img img:nth-child(6) {
animation-delay: calc(var(--time) / 1.6 * 1s);
}

.div-img img:nth-child(7) {
animation-delay: calc(var(--time) / 1.33 * 1s);
}

.div-img img:nth-child(8) {
animation-delay: calc(var(--time) / 1.14 * 1s);
}

.div-txt {
animation-duration: calc(var(--time) * 1s);
animation-iteration-count: infinite;
animation-name: color-change;
text-align: right;
}

@keyframes color-change {
0%,
25%,
100% {
background-color: #fff;
box-shadow: 0 0 0 rgba(0, 0, 0, 0.1);
}
1%,
24% {
box-shadow: 0 10px 90px rgba(0, 0, 0, 0.4);
}
}

@keyframes fade {
0%,
20%,
100% {
opacity: 0;
z-index: auto;
}
1%,
99% {
z-index: 1;
}
8%,
12% {
opacity: 1;
}
}

@media all and (min-width: 1170px) {
.div-wrap {
flex-flow: row nowrap;
justify-content: space-around;
}

我读到我可以使用 JavaScript 和 JQuery 代码,但我不知道如何使用

enter image description here

enter image description here

最佳答案

如果我没理解错的话,你想隐藏一个 block 然后显示另一个?这是基于屏幕的大小?

在要在移动设备上显示的元素上添加一个类。在要显示在桌面上的元素上添加其他类。

在移动设备上,在桌面类上添加 display: none。从桌面 (fe: 1170px) 设置 display: none on the mobile class。并在桌面类上添加 display: block(或 flex,或...)。

.div-img img {
position: absolute;
top: 0;
left: 50%;
display: block;
transform: translateX(-50%);
opacity: 0;
animation-duration: calc(var(--time) * 1s);
animation-iteration-count: infinite;
animation-name: fade;
}

.div-img img:nth-child(1) {
animation-delay: 0s;
}

.div-img img:nth-child(2) {
animation-delay: calc(var(--time) / 8 * 1s);
}

.div-img img:nth-child(3) {
animation-delay: calc(var(--time) / 4 * 1s);
}

.div-img img:nth-child(4) {
animation-delay: calc(var(--time) / 2.66 * 1s);
}

.div-img img:nth-child(5) {
animation-delay: calc(var(--time) / 2 * 1s);
}

.div-img img:nth-child(6) {
animation-delay: calc(var(--time) / 1.6 * 1s);
}

.div-img img:nth-child(7) {
animation-delay: calc(var(--time) / 1.33 * 1s);
}

.div-img img:nth-child(8) {
animation-delay: calc(var(--time) / 1.14 * 1s);
}

.div-txt {
animation-duration: calc(var(--time) * 1s);
animation-iteration-count: infinite;
animation-name: color-change;
text-align: right;
}

@keyframes color-change {
0%,
25%,
100% {
background-color: #fff;
box-shadow: 0 0 0 rgba(0, 0, 0, 0.1);
}
1%,
24% {
box-shadow: 0 10px 90px rgba(0, 0, 0, 0.4);
}
}

@keyframes fade {
0%,
20%,
100% {
opacity: 0;
z-index: auto;
}
1%,
99% {
z-index: 1;
}
8%,
12% {
opacity: 1;
}
}

@media all and (min-width: 1170px) {
.div-wrap {
flex-flow: row nowrap;
justify-content: space-around;
}
}

.block-desktop {
display: none;
}

@media all and (min-width: 1170px) {
.block-mobile {
display: none;
}

.block-desktop {
display: block;
}
}
 <div class="div-wrap">
<div class="div-wrap-txt block-mobile">
<div class="div-txt" style="padding-right: 35px;">
<p class="label">Connt</p>
<p style="color: #6B7684;">shoulders, turn<br> on it and connect application <br>with device.</p>
</div>
<div class="div-txt" style="padding-right: 35px; margin-top: 50px;">
<p class="label">Calib</p>
<p style="color: #6B7684;">calibration to help device remember your upright and slouch positions.</p>
</div>
</div>
<div class="div-img">
</div>
<div class="div-wrap-txt block-desktop">
<div class="div-txt" style="text-align: left; padding-left: 25px;">
<p class="label">Train</p>
<p style="color: #6B7684;">posture anytime you want, <br>set up daily goal to improve gradually <br>your posture.</p>
</div>
<div class="div-txt" style="text-align: left; padding-left: 25px; margin-top: 50px;">
<p class="label">Anale</p>
<p style="color: #6B7684;">Statistics let track the <br>progress you’ve made from first <br>training to the last.</p>
</div>
</div>
</div>

关于html - 将一个 block 替换为另一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53711510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com