整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          html提示信息框淡入淡出效果

          用方法:

          調用initMessagebox(“要顯示的文字”)方法即可

          <!--信息框-->
          <div id="messagebox"></div>
          <!--Load Jquery-->
           <script src="js/jquery-1.11.3.min.js"></script>
           <script>
           /*提示信息框動態效果*/
           var messageboxT;
           var top1 = 10;
           var opacity = 0;
           //初始化數據
           function initMessagebox(info) {
           top1 = 10;
           opacity = 0;
           opacity1 = 1;
           $("#messagebox").html(info);
           $("#messagebox").css({ 'display': 'block' });
           appearMessagebox();
           }
           //出現信息框
           function appearMessagebox() {
           top1 += 1;
           opacity += 0.05;
           if (opacity < 1) {
           messageboxT = setTimeout("appearMessagebox()", 15);
           }
           else {
           disappearMessagebox();
           }
           $("#messagebox").css({ 'top': String(top1) + 'px' });
           $("#messagebox").css({ 'opacity': String(opacity) });
           }
           //隱藏信息框
           function disappearMessagebox() {
           opacity -= 0.05;
           if (opacity > 0.05) {
           messageboxT = setTimeout("disappearMessagebox()", 40);
           }
           else {
           opacity = 0;
           $("#messagebox").css({ 'display': 'none' });
           }
           $("#messagebox").css({ 'opacity': String(opacity) });
           }
           </script>
          

          用到的css

          i,大家好,我是拾光;

          希望大家能夠關注我發布的作品。

          今天的主題就是【CSS文本底部淡入淡出效果】

          下面是效果圖:

          說明:由于圖中文章篇幅比較長,所以大家可以略過文章的內容,直接看代碼;

          排版可能不是特別好,希望大家能夠理解。

          HTML:

          <!DOCTYPE html>

          <head>

          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

          <title>css文本底部淡入淡出效果 - 站長素材</title>

          <link rel="stylesheet" type="text/css" href="style.css" />

          <!--[if lte IE 6]>

          <style type="text/css" media="screen">

          #bottom_fade {

          background: none;

          filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='bottom-fade.png',sizingMethod='scale');

          left: 0px;

          height: 200px;

          position: absolute;

          bottom: -18px;

          width: expression(document.body.clientWidth);

          }

          html, body {

          height: 100%; overflow: auto;

          }

          </style>

          <![endif]-->

          </head>

          <body>

          <div id="page_wrap">

          <div>

          Completely revolutionize high-quality niches after mission-critical expertise. Professionally deploy standardized total linkage before interoperable architectures. Quickly formulate future-proof meta-services through cross functional portals. Holisticly procrastinate timely results vis-a-vis principle-centered human capital. Distinctively incubate emerging systems and collaborative best practices. Compellingly exploit next-generation technology via web-enabled results.

          </div>

          </div>

          <div>

          Professionally disintermediate 24/365 web services via intermandated technologies. Holisticly disseminate flexible web services through professional results. Enthusiastically empower integrated channels and standards compliant channels. Proactively brand end-to-end process improvements rather than resource sucking results. Phosfluorescently envisioneer excellent growth strategies rather than equity invested outsourcing. Assertively build progressive data whereas process-centric processes. Dramatically visualize highly efficient sources via accurate applications. Efficiently engineer orthogonal infomediaries for cross functional ROI. Conveniently restore alternative functionalities after intermandated systems.

          </div>

          <div>

          Credibly aggregate dynamic synergy and one-to-one testing procedures. Credibly synergize out-of-the-box growth strategies via timely mindshare. Synergistically embrace extensive schemas and multidisciplinary processes. Monotonectally synergize 2.0 sources before resource-leveling sources. Professionally grow value-added results before client-based internal or "organic" sources. Uniquely network alternative processes for interoperable solutions.

          </div>

          <div>

          Quickly fabricate out-of-the-box relationships via top-line e-services. Uniquely restore market positioning synergy rather than long-term high-impact manufactured products. Monotonectally plagiarize high-payoff interfaces rather than business internal or "organic" sources. Credibly synergize plug-and-play interfaces rather than intuitive results. Compellingly expedite fully tested outsourcing vis-a-vis impactful synergy. Energistically build strategic value and excellent portals. Holisticly deliver revolutionary users before extensive value. Uniquely leverage other's low-risk high-yield e-services before multidisciplinary action items. Dynamically formulate proactive metrics via just in time e-business.

          </div>

          <div>

          Objectively parallel task 24/365 services after superior products. Competently disintermediate unique web services through unique outsourcing. Efficiently evisculate functionalized data with market positioning resources.

          </div>

          <div>

          Distinctively reconceptualize principle-centered niches rather than state of the art action items. Compellingly disseminate 24/365 convergence and standardized architectures. Continually repurpose high-payoff methods of empowerment whereas virtual relationships. Compellingly administrate professional web-readiness before worldwide bandwidth. Energistically redefine high-payoff bandwidth for empowered niches. Phosfluorescently foster backward-compatible e-tailers for backward-compatible architectures.

          </div>

          <div>

          Distinctively re-engineer impactful architectures and resource sucking niches. Authoritatively envisioneer leveraged total linkage whereas vertical value. Phosfluorescently iterate dynamic opportunities through multimedia based systems. Uniquely e-enable frictionless paradigms after B2C initiatives. Credibly deliver go forward methods of empowerment via professional total linkage. Dramatically deliver client-based portals whereas collaborative innovation. Uniquely parallel task quality opportunities before highly efficient e-tailers. Synergistically productivate world-class infomediaries and distributed content. Appropriately build equity invested e-commerce and focused process improvements. Efficiently architect holistic methods of empowerment for reliable customer service. Phosfluorescently utilize synergistic mindshare with adaptive methodologies. Seamlessly strategize best-of-breed niche markets without high-quality materials.

          </div>

          <div>

          Conveniently develop alternative total linkage via customized testing procedures. Credibly scale timely relationships whereas front-end vortals. Quickly target cost effective e-business through strategic services. Uniquely seize installed base deliverables through user-centric niche markets. Seamlessly simplify top-line strategic theme areas through corporate outsourcing. Appropriately incubate frictionless markets whereas functionalized web services.

          </div>

          <div>Assertively synthesize revolutionary technologies after competitive value.</div>

          <div id="bottom_fade"></div>

          </div>

          <div style="text-align:center;clear:both">

          </div>

          </body>

          </html>

          CSS:

          * {

          margin: 0;

          padding: 0;

          border: 0;

          }

          body {

          font-family: "Lucida Grande", Georgia, sans-serif;

          font-size: 67.5%;

          }

          p {

          font-size: 1.1em;

          line-height: 1.6em;

          }

          #page_wrap {

          width: 600px;

          z-index: 1;

          margin: 10px auto;

          }

          #bottom_fade {

          width: 600px;

          height: 200px;

          z-index: 99;

          position: fixed;

          bottom: 0px;

          background: url("bottom-fade.png") bottom center no-repeat;

          }

          素材在此,大家可以【使用電腦】點擊圖片另存為進行保存。

          今天的任務就到這里了,希望大家多多支持。

          現代網頁設計中,動畫和過渡是提升用戶體驗的重要手段。通過使用 CSS,我們可以在不影響頁面性能的前提下,實現平滑和吸引人的視覺效果。本文將介紹 CSS 動畫和過渡的基礎知識,并通過幾個例子展示如何在你的網站中應用它們。

          CSS 過渡(Transitions)

          CSS 過渡允許你在 CSS 屬性值之間創建平滑的動畫效果。當一個元素的屬性值改變時,過渡效果會在一定時間內平滑地過渡到新的屬性值。

          基本語法

          transition: property duration timing-function delay;
          
          • property:指定要添加過渡效果的 CSS 屬性。
          • duration:過渡效果的持續時間。
          • timing-function:定義速度曲線的函數。
          • delay:過渡效果的延遲時間。

          例子 1:鼠標懸停放大圖片

          img:hover {
            transform: scale(1.2);
            transition: transform 0.3s ease-in-out;
          }
          

          這個例子中,當鼠標懸停在圖片上時,圖片會在0.3秒內放大到原來的1.2倍大小,過渡效果為ease-in-out。

          CSS 動畫(Animations)

          CSS 動畫提供了更強大的控制,允許你創建復雜的動畫序列,通過定義關鍵幀(keyframes)來控制動畫的中間狀態。

          基本語法

          @keyframes animation-name {
            from {
              /* 初始狀態 */
            }
            to {
              /* 結束狀態 */
            }
          }
          

          或者使用百分比來定義多個關鍵幀:

          @keyframes animation-name {
            0% { /* 初始狀態 */ }
            50% { /* 中間狀態 */ }
            100% { /* 結束狀態 */ }
          }
          

          例子 2:無限旋轉圖標

          @keyframes spin {
            from { transform: rotate(0deg); }
            to { transform: rotate(360deg); }
          }
          
          .icon-spin {
            animation: spin 2s linear infinite;
          }
          

          這個例子創建了一個名為spin的動畫,使得圖標無限期地旋轉。

          實戰例子

          接下來,我們將通過幾個實戰例子來展示 CSS 動畫和過渡的具體應用。

          例子 3:按鈕點擊波紋效果

          .button {
            position: relative;
            overflow: hidden;
            transition: background-color 0.3s;
          }
          
          .button:after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 5px;
            height: 5px;
            background: rgba(255, 255, 255, 0.7);
            opacity: 0;
            border-radius: 100%;
            transform: scale(1, 1) translate(-50%);
            transform-origin: 50% 50%;
          }
          
          .button:active:after {
            width: 300px;
            height: 300px;
            opacity: 1;
            transition: width 0.5s, height 0.5s, opacity 0s 0.5s;
          }
          

          在這個例子中,當按鈕被點擊時,會產生一個波紋效果,模擬水波紋擴散。

          例子 4:淡入淡出切換效果

          .fade-in {
            animation: fadeIn 1s ease-in-out;
          }
          
          @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
          }
          
          .fade-out {
            animation: fadeOut 1s ease-in-out;
          }
          
          @keyframes fadeOut {
            from { opacity: 1; }
            to { opacity: 0; }
          }
          

          這個例子中定義了兩個動畫,一個用于元素的淡入,另一個用于元素的淡出。

          示例

          <!DOCTYPE html>
          <html lang="en">
          <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <title>CSS Animation and Transition Example</title>
          <style>
            body {
              font-family: 'Arial', sans-serif;
              margin: 0;
              padding: 0;
              background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
              background-size: 400% 400%;
              animation: gradientBG 15s ease infinite;
              display: flex;
              justify-content: center;
              align-items: center;
              flex-direction: column;
              min-height: 100vh;
            }
          
            @keyframes gradientBG {
              0% { background-position: 0% 50%; }
              50% { background-position: 100% 50%; }
              100% { background-position: 0% 50%; }
            }
          
            .logo {
              font-size: 2em;
              color: #007bff;
              margin-bottom: 20px;
              animation: spin 3s linear infinite;
            }
          
            .scrolling-text {
              margin: 20px 0;
              background-color: #333;
              color: #fff;
              padding: 10px;
              white-space: nowrap;
              overflow: hidden;
              position: relative;
            }
          
            .scrolling-text p {
              position: absolute;
              width: 100%;
              height: 100%;
              margin: 0;
              line-height: 50px;
              text-align: center;
              /* Starting position */
              transform: translateX(100%);
              /* Apply animation to this element */
              animation: scroll-text 10s linear infinite;
            }
          
            @keyframes scroll-text {
              0% { transform: translateX(100%); }
              100% { transform: translateX(-100%); }
            }
          
            .interactive-card {
              background-color: #fff;
              box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
              padding: 20px;
              margin: 20px;
              border-radius: 10px;
              transition: transform 0.3s ease, box-shadow 0.3s ease;
            }
          
            .interactive-card:hover {
              transform: translateY(-10px);
              box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
            }
          
            .color-block {
              width: 100px;
              height: 100px;
              background-color: #17a2b8;
              margin: 20px;
              border-radius: 50%;
              transition: background-color 0.5s ease, transform 0.5s ease;
            }
          
            .color-block:hover {
              background-color: #28a745;
              transform: rotate(180deg);
            }
          </style>
          </head>
          <body>
          
          <div class="logo">
            <i class="fas fa-sync-alt"></i> Animated Logo
          </div>
          
          <div class="scrolling-text">
            <p>This text scrolls infinitely. Pay attention to how it moves smoothly from right to left.</p>
          </div>
          
          <div class="interactive-card">
            <h3>Interactive Card</h3>
            <p>Hover over this card to see it move. It's a simple yet effective way to add interactivity to your design.</p>
          </div>
          
          <div class="color-block"></div>
          
          </body>
          </html>
          

          • .logo 類定義了一個徽標,它具有字體大小和顏色,并應用了一個名為 spin 的關鍵幀動畫,使徽標無限旋轉。
          • .scrolling-text 類定義了一個包含滾動文本的容器,設置了背景顏色、文字顏色和內邊距。
          • .scrolling-text p 選擇器定義了滾動文本的樣式,包括動畫 scroll-text,使文本從右向左無限滾動。
          • .interactive-card 類定義了一個交互式卡片,它具有背景顏色、陰影、內邊距和圓角。當鼠標懸停時,它會向上移動并增加陰影,這是通過 transition 屬性實現的。
          • .color-block 類定義了一個顏色塊,設置了寬度、高度、背景顏色和圓角。當鼠標懸停時,它的背景顏色會改變,并且會旋轉 180 度。
          • body 的背景被設置為一個線性漸變,包含四種顏色。通過 background-size 屬性,我們擴大了背景尺寸,這樣動畫在運行時會有更多的空間進行顏色的過渡。
          • @keyframes gradientBG 關鍵幀動畫被創建來改變背景的位置,從而在不同的顏色之間產生平滑過渡的效果。
          • 該動畫被設置為無限循環,并且每次循環持續 15 秒,通過 ease 時間函數來平滑過渡。

          結語

          CSS 動畫和過渡是前端開發者的強大工具,它們可以在不犧牲性能的情況下為用戶提供流暢、引人注目的界面交互。通過掌握這些技術,你可以創造出更加動態和生動的網頁體驗。記住,動畫應該用來增強用戶體驗,而不是分散用戶的注意力,適量而恰當地使用動畫效果是關鍵。


          主站蜘蛛池模板: 国产主播在线一区| 国产精品一区二区三区99| 久久久91精品国产一区二区| 亚洲国产日韩在线一区| 99久久精品费精品国产一区二区| 精品国产一区二区三区久久久狼| 国产Av一区二区精品久久| 亚洲国产成人久久一区WWW| 国产香蕉一区二区精品视频| 精品在线一区二区三区| 欲色aV无码一区二区人妻| 国产一区二区三区在线2021| 日韩一区二区三区在线观看 | 精品女同一区二区三区免费播放| 色噜噜狠狠一区二区三区果冻| 亚洲AV无码一区二区三区在线观看 | 视频一区二区中文字幕| 亚洲丰满熟女一区二区v| 日本免费电影一区二区 | 无码国产亚洲日韩国精品视频一区二区三区 | 国产一区二区在线视频| 亚洲一区二区高清| 无遮挡免费一区二区三区| 天堂成人一区二区三区| 亚洲日韩国产一区二区三区在线 | 一区二区三区四区精品| 日本一道一区二区免费看| 精品无码国产一区二区三区51安| 亚洲av一综合av一区| 亚洲乱色熟女一区二区三区丝袜| 久夜色精品国产一区二区三区| 国产在线一区二区三区av| 精品无码国产AV一区二区三区 | 福利一区二区在线| 加勒比精品久久一区二区三区| 日本精品啪啪一区二区三区| 日韩人妻无码免费视频一区二区三区| 久久久久久人妻一区二区三区 | 无码人妻久久久一区二区三区| 国产综合精品一区二区三区| 国产丝袜美女一区二区三区|