gpt4 book ai didi

html - slideOut 侧边栏再次出现

转载 作者:行者123 更新时间:2023-11-28 14:47:47 27 4
gpt4 key购买 nike

我有一个可以滑入/滑出的边栏。当我在按钮上滑出时,按下它会向右滑动以隐藏,但在应该隐藏时会再次出现。

侧边栏在单击按钮时出现,在您按 x 图标时隐藏

CSS

.pay-storage-container {
$inner-padding: 16px;
height: 100vh;
position: fixed;
right: 0;
top: 0;
width: 325px;
border: 1px solid #c0c2c7;
z-index: 1;
//Other subclasses
}

.showSideBar {
animation: slideIn 1s;
}

.closeSideBar {
animation: slideOut 1s;
}

@keyframes slideIn {
0% {
opacity: 0;
transform: translateX(350px);
}

100% {
opacity: 1;
transform: translate(0);
}
}

@keyframes slideOut {
100% {
opacity: 1;
transform: translateX(350px);
}
}

HTML

<div class="pay-storage-container {{toggleSideBar ? 'showSideBar' : 'closeSideBar'}}">
<div class="header-container">
<div class="header">Pay Storage</div>
<span class='close-icon csx-common_delete' (click)="closeSideBar()"></span>
</div>
<div class="pay-storage-inner">
<div *ngIf="paymentMessage$ | async as message">
{{ message | json }}
</div>
<app-equipment-summary [equipmentSummary]='equipmentSummary'></app-equipment-summary>
<app-credit-card #creditCardForm></app-credit-card>
<div>
</div>
</div>
<div class="footer-container">
<button pButton type="button" label="Submit Payment" class="x-primary-green-400" [disabled]='!creditCardForm.creditCardForm.valid'
(click)="onSubmitPayment()"></button>
</div>
</div>

我在这个元素中使用 angular,我在 .TS 文件中有一个变量,它切换类以更改滑入/滑出。

TS

toggleSideBar = true;
.
.
.
closeSideBar() {
this.toggleSideBar = false;
}

我很厉害,这是 css 的问题,而不是 Angular 边的问题,但我还是补充说,以防你们都想看一看

最佳答案

您可以将 animation-fill-mode: forwards; 添加到 closeSideBar 类。这将确保动画在达到 100% 后不会重置

.pay-storage-container {
$inner-padding: 16px;
height: 100vh;
position: fixed;
right: 0;
top: 0;
width: 325px;
border: 1px solid #c0c2c7;
z-index: 1;
//Other subclasses
}

.showSideBar {
animation: slideIn 1s;
}

.closeSideBar {
animation: slideOut 1s;
animation-fill-mode: forwards;
}

@keyframes slideIn {
0% {
opacity: 0;
transform: translateX(350px);
}

100% {
opacity: 1;
transform: translate(0);
}
}

@keyframes slideOut {
100% {
opacity: 1;
transform: translateX(350px);
}
}
<div class="pay-storage-container closeSideBar">
<div class="header-container">
<div class="header">Pay Storage</div>
<span class='close-icon csx-common_delete' (click)="closeSideBar()"></span>
</div>
<div class="pay-storage-inner">
<div *ngIf="paymentMessage$ | async as message">
{{ message | json }}
</div>
<app-equipment-summary [equipmentSummary]='equipmentSummary'></app-equipment-summary>
<app-credit-card #creditCardForm></app-credit-card>
<div>
</div>
</div>
<div class="footer-container">
<button pButton type="button" label="Submit Payment" class="x-primary-green-400" [disabled]='!creditCardForm.creditCardForm.valid'
(click)="onSubmitPayment()"></button>
</div>

关于html - slideOut 侧边栏再次出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52081464/

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