CSS製作圖形變形彈出的效果

來源:互聯網
上載者:User
這篇文章主要介紹了一個CSS製作圖形變形彈出效果的樣本分享,彈出窗的大小可以使用jQuery來修改,需要的朋友可以參考下

彈出表單是網頁常用的一個互動設計,在這個注重互動動畫體驗的時代,網頁彈窗也可以來點新鮮的點子,比如今天分享的CSS 變形Modal Window。

當使用者點擊按鈕時,按鈕將會變成一個全屏的螢幕,然後再顯示內容,整個展示過程流暢友好,也許你可以嘗試到你的新項目上。

示範頁:http://codyhouse.co/gem/morphing-modal-window/
點擊“Fire Modal Window”按鈕後,按鈕將會慢慢變大,直到整個螢幕。下面來個GIF示範:

使用教程

本代碼相容Chrome, Firefox, Safari, Opera,而IE需要9.0或以上版本(IE9+)

STEP 1: 建立HTML布局

<section class="cd-section"><!-- section content here --><p class="cd-modal-action"><a href="#0" class="btn" data-type="modal-trigger">Fire Modal Window</a> <!— 這是表單按鈕 --><span class="cd-modal-bg"></span></p><p class="cd-modal"><p class="cd-modal-content"><!— 這是表單內容地區 --></p></p><a href="#0" class="cd-modal-close">Close</a> <!— 這是關閉按鈕 --></section>

STEP 2: 添加CSS樣式

.cd-modal-action {   position: relative;   }   .cd-modal-action .btn {   width: 12.5em;   height: 4em;   background-color: #123758;   border-radius: 5em;   transition: color 0.2s 0.3s, width 0.3s 0s;   }   .cd-modal-action .btn.to-circle {   width: 4em;   color: transparent;   transition: color 0.2s 0s, width 0.3s 0.2s;   }   .cd-modal-action .cd-modal-bg {   position: absolute;   top: 0;   left: 50%;   transform: translateX(-2em);   width: 4em;   height: 4em;   background-color: #123758;   border-radius: 50%;   opacity: 0;   visibility: hidden;   transition: visibility 0s 0.5s;   }   .cd-modal-action .cd-modal-bg.is-visible {   opacity: 1;   visibility: visible;   }

STEP 3: 添加jQuery

本代碼使用了jQuery,你可以通過下面代碼來修改視窗大小。

var btnRadius = $('.cd-modal-bg').width()/2,   left = $('.cd-modal-bg').offset().left + btnRadius,   top = $('.cd-modal-bg').offset().top + btnRadius - $(window).scrollTop(),   scale = scaleValue(top, left, btnRadius, $(window).height(), $(window).width());   function scaleValue( topValue, leftValue, radiusValue, windowW, windowH) {   var maxDistHor = ( leftValue > windowW/2) ? leftValue : (windowW - leftValue),   maxDistVert = ( topValue > windowH/2) ? topValue : (windowH - topValue);   return Math.ceil(Math.sqrt( Math.pow(maxDistHor, 2) + Math.pow(maxDistVert, 2) )/radiusValue);   }

以上就是本文的全部內容,希望對大家的學習有所協助,更多相關內容請關注topic.alibabacloud.com!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.