<rt id="kp4f2"><optgroup id="kp4f2"></optgroup></rt>
  • <label id="kp4f2"></label>
    1. <thead id="kp4f2"></thead>
    2. <\/div>
      <\/div> <\/div>
      <\/div>
      <\/div> <\/div>
      <\/div>
      <\/div> <\/div> <\/div> <\/body><\/pre>

      3.CSS:<\/strong>切分圖片:<\/strong>將一張完整的圖切成7塊,各自進(jìn)行不同的動(dòng)畫。在沒有切圖的情況下,如何讓圖片分成7塊:設(shè)置7個(gè)div,每個(gè)div寬度為圖片的1\/7,position:absolute,且每個(gè)div的backgroundPosition的x值由0逐漸遞減1\/7.<\/p>

      64LL4E2OL83]ED{]CQ6I0`J.png <\/p> <\/p>

      (圖中藍(lán)色部分為背景圖,每個(gè)div都插入同一背景圖,通過設(shè)置backgroundPosition,讓圖片沿X軸左移,即可7個(gè)div都顯示對(duì)應(yīng)的部分,構(gòu)成完整的一張圖)<\/p>

      關(guān)鍵樣式:<\/strong><\/p>

      .bcwd{    background: url(..\/img\/sample2.jpg) no-repeat;    background-size: 600px 400px;    \/*背面的圖片默認(rèn)狀態(tài),背對(duì)正面,且上下顛倒(使選裝之后上下不顛倒)*\/    -webkit-transform: rotateY(180deg) rotateZ(180deg); }.fwd{    position: absolute;    top: 0;    background: url(..\/img\/sample1.jpg) no-repeat;    background-size: 600px 400px;}<\/pre>   

      解釋一下第五行中的這行代碼:-webkit-transform: rotateY(180deg) rotateZ(180deg);如果只是在fwd和bcwd div繪制圖片,會(huì)在圖中的面1、3分別顯示圖片1、2,但正確的應(yīng)是面1為正面(圖1),面2、3緊貼一起,面4為背面(圖2),這樣才可以做到正面div向前旋轉(zhuǎn)180度后背面成為正面,且背面圖片是正的。為實(shí)現(xiàn)上述效果,bcwd div就要沿Y軸旋轉(zhuǎn)180度,變成面4顯示圖片,再沿Z軸旋轉(zhuǎn)180度,是背面圖片旋轉(zhuǎn)為正面時(shí),圖片不是倒過來的。<\/p>

      2.png <\/p> <\/p>

      js設(shè)置樣式:<\/strong><\/p>

                      var bcwd = document.getElementsByClassName('bcwd');                var fwd = document.getElementsByClassName('fwd');                for (var i = 0; i < inner.length; i++) {                    \/\/設(shè)置bcwd和back的位置(left background-position)                    bcwd[i].style.left = 85.72 * i + 'px';                    bcwd[i].style.backgroundPosition = '-' + 85.72 * i + 'px 0';                    fwd[i].style.left = 85.72 * i + 'px';                    fwd[i].style.backgroundPosition = '-' + 85.72 * i + 'px 0';                                    }<\/pre>   

      4.JS:<\/strong>實(shí)現(xiàn)動(dòng)畫間隔一段時(shí)間后正面轉(zhuǎn)向背面,再間隔一段時(shí)間后,背面轉(zhuǎn)為正面。<\/p>

      .inner_div.r{    -webkit-transform: rotateX(180deg);    \/*正面轉(zhuǎn)為背面,背面轉(zhuǎn)為正面*\/    -webkit-transition: -webkit-transform 1s ease-in-out;}<\/pre>   
                      setInterval(function(){                    go();                },2000);                var index = 2,nextIndex = 3; \/\/用于計(jì)算第幾張圖片                inner[0].addEventListener(\"webkitTransitionEnd\", function () {                                \/\/換背景圖(此時(shí),fwd在背面。bcwd在正面)                    if(index == 4)                        nextIndex = 1;        \/\/最后一張圖片與第一張圖片的切換                    else                            nextIndex = index + 1;                    for (var j = 0; j < fwd.length; j++) {    \/\/fwd的圖片替換成當(dāng)前圖片                            fwd[j].style.backgroundImage = 'url(img\/sample' + index + '.jpg)';                        }                    reset();                    \/\/fwd旋轉(zhuǎn)為正面,bcwd旋轉(zhuǎn)為背面                    for (var j = 0; j < fwd.length; j++) {    \/\/bcwd的圖片替換成下一張圖片                            bcwd[j].style.backgroundImage = 'url(img\/sample' + nextIndex + '.jpg)';                        }                    index = nextIndex;                });<\/pre>   
                  \/\/實(shí)現(xiàn)背面轉(zhuǎn)向正面            function go () {                setTimeout(function() {                    inner[3].classList.add(\"r\");                    setTimeout(function() {                        inner[2].classList.add(\"r\");                        inner[4].classList.add(\"r\");                        setTimeout(function() {                            inner[1].classList.add(\"r\");                            inner[5].classList.add(\"r\");                            setTimeout(function() {                                inner[0].classList.add(\"r\");                                inner[6].classList.add(\"r\");                            }, 200);    \/\/時(shí)間可以改變,但是4個(gè)時(shí)間相加總和+動(dòng)畫旋轉(zhuǎn)時(shí)間(css 1s)要小于上邊setTimout的總時(shí)間                        }, 200);                    }, 200);                }, 200)            }\/\/實(shí)現(xiàn)正面轉(zhuǎn)為背面            function reset () {                for (var m = 0;m   

      目前效果:<\/p>

      multi-flip.gif <\/p> <\/p>

      (是否感覺有一片一片的生硬感呢?)5.升華:<\/strong>添加以下2句CSS即可解決:<\/p>

      .outer_box{    -webkit-transform-style: preserve-3d;    -webkit-perspective: 2000;        \/*增強(qiáng)3D效果*\/}<\/pre>   

      6.補(bǔ)充:<\/strong>1.backface-visibility: visible|hidden;定義當(dāng)元素不面向屏幕時(shí)是否可見。visible:背面是可見的。hidden:背面不可見的。2.以下兩句很有用處,增強(qiáng)3D效果,大大提升動(dòng)畫效果??!-webkit-transform-style: preserve-3d; -webkit-perspective: 2000;3.完整代碼晚點(diǎn)揭曉。<\/p> "}

      国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

      Home Web Front-end HTML Tutorial CSS3動(dòng)畫(3):transform實(shí)現(xiàn)multi-flip動(dòng)畫_html/css_WEB-ITnose

      CSS3動(dòng)畫(3):transform實(shí)現(xiàn)multi-flip動(dòng)畫_html/css_WEB-ITnose

      Jun 21, 2016 am 08:46 AM

      今天給大家?guī)碜詣?dòng)輪播的multi-flip動(dòng)畫,o(^▽^)o,不知道什么是multi-flip沒關(guān)系,來張效果圖就懂了->

      multi-flip2.gif

      1.總體思路有正面7個(gè)div,背面7個(gè)div,重疊在一起,正面一張圖片,背面另外一張圖片(如一張紙的正反面畫著不同的圖畫),正面旋轉(zhuǎn)180度后顯示背面的圖片,并將原本正面div的圖片替換成原本背面的div的圖片,背面旋轉(zhuǎn)180度,顯示正面(此時(shí)回到最初的位置狀態(tài)),一直循環(huán)。簡單來說:正面div旋轉(zhuǎn),替換,轉(zhuǎn)回,背面div替換成下張圖片,以此一直循環(huán)下去。(單純看文字有點(diǎn)難以理解,我們直接來看看“廬山真面目”)2.HTML:先看html,有個(gè)整體了解。

          <body>        <div class="outer_box">            <div id="d0" class="inner_div">                <div  class="bcwd"></div><!--背面的div-->                <div  class="fwd"></div><!--正面的div-->            </div>            <div id="d1" class="inner_div">                <div  class="bcwd"></div>                <div  class="fwd"></div>            </div>            <!--此處省略div id="d2"-"d5"的書寫(代碼相同)-->            <div id="d6" class="inner_div">                <div  class="bcwd"></div>                <div  class="fwd"></div>            </div>        </div>    </body>

      3.CSS:切分圖片:將一張完整的圖切成7塊,各自進(jìn)行不同的動(dòng)畫。在沒有切圖的情況下,如何讓圖片分成7塊:設(shè)置7個(gè)div,每個(gè)div寬度為圖片的1/7,position:absolute,且每個(gè)div的backgroundPosition的x值由0逐漸遞減1/7.

      64LL4E2OL83]ED{]CQ6I0`J.png

      (圖中藍(lán)色部分為背景圖,每個(gè)div都插入同一背景圖,通過設(shè)置backgroundPosition,讓圖片沿X軸左移,即可7個(gè)div都顯示對(duì)應(yīng)的部分,構(gòu)成完整的一張圖)

      關(guān)鍵樣式:

      .bcwd{    background: url(../img/sample2.jpg) no-repeat;    background-size: 600px 400px;    /*背面的圖片默認(rèn)狀態(tài),背對(duì)正面,且上下顛倒(使選裝之后上下不顛倒)*/    -webkit-transform: rotateY(180deg) rotateZ(180deg); }.fwd{    position: absolute;    top: 0;    background: url(../img/sample1.jpg) no-repeat;    background-size: 600px 400px;}

      解釋一下第五行中的這行代碼:-webkit-transform: rotateY(180deg) rotateZ(180deg);如果只是在fwd和bcwd div繪制圖片,會(huì)在圖中的面1、3分別顯示圖片1、2,但正確的應(yīng)是面1為正面(圖1),面2、3緊貼一起,面4為背面(圖2),這樣才可以做到正面div向前旋轉(zhuǎn)180度后背面成為正面,且背面圖片是正的。為實(shí)現(xiàn)上述效果,bcwd div就要沿Y軸旋轉(zhuǎn)180度,變成面4顯示圖片,再沿Z軸旋轉(zhuǎn)180度,是背面圖片旋轉(zhuǎn)為正面時(shí),圖片不是倒過來的。

      2.png

      js設(shè)置樣式:

                      var bcwd = document.getElementsByClassName('bcwd');                var fwd = document.getElementsByClassName('fwd');                for (var i = 0; i < inner.length; i++) {                    //設(shè)置bcwd和back的位置(left background-position)                    bcwd[i].style.left = 85.72 * i + 'px';                    bcwd[i].style.backgroundPosition = '-' + 85.72 * i + 'px 0';                    fwd[i].style.left = 85.72 * i + 'px';                    fwd[i].style.backgroundPosition = '-' + 85.72 * i + 'px 0';                                    }

      4.JS:實(shí)現(xiàn)動(dòng)畫間隔一段時(shí)間后正面轉(zhuǎn)向背面,再間隔一段時(shí)間后,背面轉(zhuǎn)為正面。

      .inner_div.r{    -webkit-transform: rotateX(180deg);    /*正面轉(zhuǎn)為背面,背面轉(zhuǎn)為正面*/    -webkit-transition: -webkit-transform 1s ease-in-out;}
                      setInterval(function(){                    go();                },2000);                var index = 2,nextIndex = 3; //用于計(jì)算第幾張圖片                inner[0].addEventListener("webkitTransitionEnd", function () {                                //換背景圖(此時(shí),fwd在背面。bcwd在正面)                    if(index == 4)                        nextIndex = 1;        //最后一張圖片與第一張圖片的切換                    else                            nextIndex = index + 1;                    for (var j = 0; j < fwd.length; j++) {    //fwd的圖片替換成當(dāng)前圖片                            fwd[j].style.backgroundImage = 'url(img/sample' + index + '.jpg)';                        }                    reset();                    //fwd旋轉(zhuǎn)為正面,bcwd旋轉(zhuǎn)為背面                    for (var j = 0; j < fwd.length; j++) {    //bcwd的圖片替換成下一張圖片                            bcwd[j].style.backgroundImage = 'url(img/sample' + nextIndex + '.jpg)';                        }                    index = nextIndex;                });
                  //實(shí)現(xiàn)背面轉(zhuǎn)向正面            function go () {                setTimeout(function() {                    inner[3].classList.add("r");                    setTimeout(function() {                        inner[2].classList.add("r");                        inner[4].classList.add("r");                        setTimeout(function() {                            inner[1].classList.add("r");                            inner[5].classList.add("r");                            setTimeout(function() {                                inner[0].classList.add("r");                                inner[6].classList.add("r");                            }, 200);    //時(shí)間可以改變,但是4個(gè)時(shí)間相加總和+動(dòng)畫旋轉(zhuǎn)時(shí)間(css 1s)要小于上邊setTimout的總時(shí)間                        }, 200);                    }, 200);                }, 200)            }//實(shí)現(xiàn)正面轉(zhuǎn)為背面            function reset () {                for (var m = 0;m<inner.length;m++) {                    inner[m].classList.remove("r");                }            }

      目前效果:

      multi-flip.gif

      (是否感覺有一片一片的生硬感呢?)5.升華:添加以下2句CSS即可解決:

      .outer_box{    -webkit-transform-style: preserve-3d;    -webkit-perspective: 2000;        /*增強(qiáng)3D效果*/}

      6.補(bǔ)充:1.backface-visibility: visible|hidden;定義當(dāng)元素不面向屏幕時(shí)是否可見。visible:背面是可見的。hidden:背面不可見的。2.以下兩句很有用處,增強(qiáng)3D效果,大大提升動(dòng)畫效果??!-webkit-transform-style: preserve-3d; -webkit-perspective: 2000;3.完整代碼晚點(diǎn)揭曉。

      Statement of this Website
      The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

      Hot AI Tools

      Undress AI Tool

      Undress AI Tool

      Undress images for free

      Undresser.AI Undress

      Undresser.AI Undress

      AI-powered app for creating realistic nude photos

      AI Clothes Remover

      AI Clothes Remover

      Online AI tool for removing clothes from photos.

      Clothoff.io

      Clothoff.io

      AI clothes remover

      Video Face Swap

      Video Face Swap

      Swap faces in any video effortlessly with our completely free AI face swap tool!

      Hot Tools

      Notepad++7.3.1

      Notepad++7.3.1

      Easy-to-use and free code editor

      SublimeText3 Chinese version

      SublimeText3 Chinese version

      Chinese version, very easy to use

      Zend Studio 13.0.1

      Zend Studio 13.0.1

      Powerful PHP integrated development environment

      Dreamweaver CS6

      Dreamweaver CS6

      Visual web development tools

      SublimeText3 Mac version

      SublimeText3 Mac version

      God-level code editing software (SublimeText3)

      Hot Topics

      PHP Tutorial
      1502
      276
      Implementing Clickable Buttons Using the HTML button Element Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM

      To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this

      Configuring Document Metadata Within the HTML head Element Configuring Document Metadata Within the HTML head Element Jul 09, 2025 am 02:30 AM

      Metadata in HTMLhead is crucial for SEO, social sharing, and browser behavior. 1. Set the page title and description, use and keep it concise and unique; 2. Add OpenGraph and Twitter card information to optimize social sharing effects, pay attention to the image size and use debugging tools to test; 3. Define the character set and viewport settings to ensure multi-language support is adapted to the mobile terminal; 4. Optional tags such as author copyright, robots control and canonical prevent duplicate content should also be configured reasonably.

      Best HTML tutorial for beginners in 2025 Best HTML tutorial for beginners in 2025 Jul 08, 2025 am 12:25 AM

      TolearnHTMLin2025,chooseatutorialthatbalanceshands-onpracticewithmodernstandardsandintegratesCSSandJavaScriptbasics.1.Prioritizehands-onlearningwithstep-by-stepprojectslikebuildingapersonalprofileorbloglayout.2.EnsureitcoversmodernHTMLelementssuchas,

      HTML for email templates tutorial HTML for email templates tutorial Jul 10, 2025 pm 02:01 PM

      How to make HTML mail templates with good compatibility? First, you need to build a structure with tables to avoid using div flex or grid layout; secondly, all styles must be inlined and cannot rely on external CSS; then the picture should be added with alt description and use a public URL, and the buttons should be simulated with a table or td with background color; finally, you must test and adjust the details on multiple clients.

      How to associate captions with images or media using the html figure and figcaption elements? How to associate captions with images or media using the html figure and figcaption elements? Jul 07, 2025 am 02:30 AM

      Using HTML sums allows for intuitive and semantic clarity to add caption text to images or media. 1. Used to wrap independent media content, such as pictures, videos or code blocks; 2. It is placed as its explanatory text, and can be located above or below the media; 3. They not only improve the clarity of the page structure, but also enhance accessibility and SEO effect; 4. When using it, you should pay attention to avoid abuse, and apply to content that needs to be emphasized and accompanied by description, rather than ordinary decorative pictures; 5. The alt attribute that cannot be ignored, which is different from figcaption; 6. The figcaption is flexible and can be placed at the top or bottom of the figure as needed. Using these two tags correctly helps to build semantic and easy to understand web content.

      What are the most commonly used global attributes in html? What are the most commonly used global attributes in html? Jul 10, 2025 am 10:58 AM

      class, id, style, data-, and title are the most commonly used global attributes in HTML. class is used to specify one or more class names to facilitate style setting and JavaScript operations; id provides unique identifiers for elements, suitable for anchor jumps and JavaScript control; style allows for inline styles to be added, suitable for temporary debugging but not recommended for large-scale use; data-properties are used to store custom data, which is convenient for front-end and back-end interaction; title is used to add mouseover prompts, but its style and behavior are limited by the browser. Reasonable selection of these attributes can improve development efficiency and user experience.

      How to handle forms submission in HTML without a server? How to handle forms submission in HTML without a server? Jul 09, 2025 am 01:14 AM

      When there is no backend server, HTML form submission can still be processed through front-end technology or third-party services. Specific methods include: 1. Use JavaScript to intercept form submissions to achieve input verification and user feedback, but the data will not be persisted; 2. Use third-party serverless form services such as Formspree to collect data and provide email notification and redirection functions; 3. Use localStorage to store temporary client data, which is suitable for saving user preferences or managing single-page application status, but is not suitable for long-term storage of sensitive information.

      Implementing Native Lazy Loading for Images in HTML Implementing Native Lazy Loading for Images in HTML Jul 12, 2025 am 12:48 AM

      Native lazy loading is a built-in browser function that enables lazy loading of pictures by adding loading="lazy" attribute to the tag. 1. It does not require JavaScript or third-party libraries, and is used directly in HTML; 2. It is suitable for pictures that are not displayed on the first screen below the page, picture gallery scrolling add-ons and large picture resources; 3. It is not suitable for pictures with first screen or display:none; 4. When using it, a suitable placeholder should be set to avoid layout jitter; 5. It should optimize responsive image loading in combination with srcset and sizes attributes; 6. Compatibility issues need to be considered. Some old browsers do not support it. They can be used through feature detection and combined with JavaScript solutions.

      See all articles