


Angular 2 的 ngIf 和 CSS 過渡/動畫
如何在 Angular 2 中使用 CSS 將 div 從右側滑入?
<code class="html"><div class="note"> <p> Notes</p> </div> <button class="btn btn-default">Toggle</button></code>
.transition{ -webkit-transition: opacity 1000ms ease-in-out,margin-left 500ms ease-in-out; -moz-transition: opacity 1000ms ease-in-out,margin-left 500ms ease-in-out; -ms-transition: opacity 1000ms ease-in-out,margin-left 500ms ease-in-out ; -o-transition: opacity 1000ms ease-in-out,margin-left 500ms ease-in-out; transition: opacity 1000ms ease-in-out,margin-left 500ms ease-in-out; margin-left: 1500px; width: 200px; opacity: 0; } .transition{ opacity: 100; margin-left: 0; }
如果僅使用 [ngClass] 來切換類,並且 利用 opacity,則該程式碼可以正常工作。但不想讓該元素從一開始就被渲染,所以先用 ngIf "隱藏"它,但此時過渡將不起作用。
更新 4.1.0
使用了過渡動畫API,無需再利用 [hidden] 或 [*ngIf hidden]。
更新2.1.0
<code class="typescript">import { trigger, style, animate, transition } from '@angular/animations'; @Component({ selector: 'my-app', animations: [ trigger( 'enterAnimation', [ transition(':enter', [ style({transform: 'translateX(100%)', opacity: 0}), animate('500ms', style({transform: 'translateX(0)', opacity: 1})) ]), transition(':leave', [ style({transform: 'translateX(0)', opacity: 1}), animate('500ms', style({transform: 'translateX(100%)', opacity: 0})) ]) ] ) ], template: ` <button>toggle show ({{show}})</button> <div>xxx</div> ` }) export class App { show:boolean = false; }</code>
原始回答🎜>
當表達式變成false 時,*ngIf 會從DOM 移除元素,一個不存在的元素是無法進行過渡的。
可以使用 hidden 屬性來取代:
<code class="html"><div class="note"></div></code>
以上是以下是幾種可能的標題: 1. How to Make CSS Transitions Work with `ngIf` in Angular 2? 2. Why Does `ngIf` Break My CSS Transitions in Angular 2? 3. Angular 2: Combining `ngIf` and CSS Animations for Smooth Trans的詳細內容。更多資訊請關注PHP中文網其他相關文章!

CSS盒子陰影和輪廓屬性獲得了主題。讓我們查看一些在真實主題中起作用的示例,以及我們必須將這些樣式應用於WordPress塊和元素的選項。

本教程演示了使用智能表單框架創建外觀專業的JavaScript表單(注意:不再可用)。 儘管框架本身不可用,但原理和技術仍然與其他形式的建築商相關。

這是我們在形式可訪問性上進行的小型系列中的第三篇文章。如果您錯過了第二篇文章,請查看“以:focus-visible的管理用戶焦點”。在

構建內聯文本編輯器並不是微不足道的。 該過程首先要使目標元素可編輯,並在此過程中處理潛在的語法異常。 創建編輯器來構建此編輯器,您需要動態修改內容

Svelte Transition API提供了一種使組件輸入或離開文檔(包括自定義Svelte Transitions)時動畫組件的方法。

本文探討了Envato Market上可用的PHP表單構建器腳本,比較了其功能,靈活性和設計。 在研究特定選項之前,讓我們了解PHP形式構建器是什麼以及為什麼要使用一個。 PHP形式

該教程通過使用node.js,express和multer構建文件上傳系統來指導您。 我們將介紹單個和多個文件上傳,甚至演示在MongoDB數據庫中存儲圖像以進行以後的檢索。 首先,設置您的projec


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

Dreamweaver CS6
視覺化網頁開發工具

禪工作室 13.0.1
強大的PHP整合開發環境

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

Atom編輯器mac版下載
最受歡迎的的開源編輯器