iT邦幫忙

0

snapchat 這個動畫是怎麼實現的?

  • 分享至 

  • twitterImage

https://kit.snapchat.com/portal/apps

登入後點

就會出現

只是出現的這段過程的動畫很明顯是自己設計的
請問這能怎麼實現????

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

5
暐翰
iT邦大師 1 級 ‧ 2018-06-19 14:57:40
最佳解答

純JS+CSS版本:

可以用圖片 + 按鍵事件 + Modal 實現


主要邏輯在點選圖片的時候
彈跳出modal
這段使用JSstyle.display='block'實現開啟效果
當按(X)按鈕的時候隱藏modal,使用style.display = "none"實現關閉效果

<body>

    <h2>IT邦你好</h2>
    <button onclick="document.getElementById('modal_id').style.display='block'">
        <img src="https://i.imgur.com/WCBS1DF.png"  width="420" height="420">
    </button>
    <div id="modal_id" class="modal">
        <form class="modal-content animate" action="https://i.imgur.com/ACmutwk.png">
            <div class="imgcontainer">
                <span onclick="document.getElementById('modal_id').style.display='none'" class="close" title="Close Modal">&times;</span>
                <img src="https://i.imgur.com/ACmutwk.png" alt="Avatar" class="avatar">
            </div>

            <div class="container">
                <label>
                    <b>Diplay name</b>
                </label>
                <input type="text" placeholder="Enter APP Name" name="AppName" required>
                <label>
                    <b>SET PERMISSIONS:</b>
                </label>
                <button type="submit">Continue</button>
                <button >CANCEL</button>
            </div>
        </form>
    </div>

    <script>
        // 當點圖片的時候顯示modal
        var modal = document.getElementById('modal_id');

        window.onclick = function (event) {
            if (event.target == modal) {
                modal.style.display = "none";
            }
        }
    </script>

</body>

以下是CSS

    <style>
		/*input格式*/
        input[type=text] {
            width: 100%;
            padding: 12px 20px;
            margin: 8px 0;
            display: inline-block;
            border: 1px solid #ccc;
            box-sizing: border-box;
        }

		/*按鈕格式*/
        button {
            padding: 14px 20px;
            margin: 8px 0;
            border: none;
            cursor: pointer;
            width: 100%;
        }


		/*圖片致中*/
        .imgcontainer {
            text-align: center;
            margin: 24px 0 12px 0;
            position: relative;
        }

        /* Modal的外觀設定 */
        .container {
            padding: 16px;
        }  
        span.psw {
            float: right;
            padding-top: 16px;
        }        
        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgb(0, 0, 0);
            background-color: rgba(0, 0, 0, 0.4);
            padding-top: 60px;
        }
        .modal-content {
            background-color: #fefefe;
            margin: 5% auto 15% auto;
            border: 1px solid #888;
            width: 80%;
        }

        /* 關閉按鈕 */
        .close {
            position: absolute;
            right: 25px;
            top: 0;
            color: #000;
            font-size: 35px;
            font-weight: bold;
        }

		/*動畫:點擊圖片慢慢放大*/
        .animate {
            -webkit-animation: animatezoom 0.6s;
            animation: animatezoom 0.6s
        }
        
        @-webkit-keyframes animatezoom {
            from {
                -webkit-transform: scale(0)
            }
            to {
                -webkit-transform: scale(1)
            }
        }

        @keyframes animatezoom {
            from {
                transform: scale(0)
            }
            to {
                transform: scale(1)
            }
        }

 
    </style>

效果圖(簡單用一下,有點醜請見諒):


火爆浪子 iT邦研究生 1 級 ‧ 2018-06-20 12:05:45 檢舉

神之答案!感謝提供思路,我自己按照你的來寫一個

好用心 !!

暐翰 iT邦大師 1 級 ‧ 2018-06-20 13:44:24 檢舉

有問題再跟我說 : )

我要發表回答

立即登入回答