澳门新萄京官方网站-www.8455.com-澳门新萄京赌场网址

SO销路好问答,音信头条淡入淡出效果

2019-10-02 作者:澳门新萄京赌场网址   |   浏览(185)

SO火爆问答:可认为半个字符应用CSS样式吗?

2014/06/13 · CSS · CSS

本文由 伯乐在线 - Carman 翻译。未经许可,制止转发!
藏语出处:stackoverflow。款待参加翻译组。

很酷的HTML5电子书翻页动画特效,

本文分享一款很酷的HTML5电子书翻页动画特效,那款HTML5翻页动画能够用鼠标拖动页面来效仿手动翻页的机能,也得以点击书页的边框来比一点也不慢翻页。在此以前也享受过一款HTML5 3D书本翻页特效,3D视觉效果特别鲜明。

澳门新萄京官方网站 1

在线演示地址如下:

兑现的代码:

XML/HTML Code复制内容到剪贴板

  1. <div id="shineflip">  
  2.       <div id="shineflip-pages">  
  3.           <canvas id="shineflip-canvas"></canvas>  
  4.           <canvas id="shineflip-page-mid-canvas"></canvas>  
  5.           <section class="page">  
  6.               <div><img src="images/0.jpg" width="475" height="482" /></div>  
  7.               <span style="left:18px;"><img src="images/zh.png" height="482" /></span>  
  8.           </section>  
  9.           <section class="page" style="background:url(images/left_pk.jpg)">  
  10.               <div><img src="images/1.jpg" width="466" height="463" style="float:right;margin-top:9px;" /></div>  
  11.           </section>  
  12.           <section class="page">  
  13.               <div><img src="images/2.jpg" width="466" height="463" style="float:left;margin-top:9px;" /></div>  
  14.           </section>  
  15.           <section class="page">  
  16.               <div><img src="images/3.jpg" width="466" height="463" style="float:right;margin-top:9px;" /></div>  
  17.           </section>  
  18.           <section class="page">  
  19.               <div><img src="images/4.jpg" width="466" height="463" style="float:left;margin-top:9px;" /></div>  
  20.           </section>  
  21.           <section class="page">  
  22.               <div><img src="images/5.jpg" width="466" height="463" style="float:right;margin-top:9px;" /></div>  
  23.           </section>  
  24.           <section class="page" style="background:url(images/right_pk.jpg)">  
  25.               <div><img src="images/6.jpg" width="466" height="463" style="float:left;margin-top:9px;" /></div>  
  26.           </section>  
  27.           <section class="page">  
  28.               <div><img src="images/24.jpg" width="475" height="482" /></div>  
  29.               <span style="right:18px;"><img src="images/zh.png" height="482" /></span>  
  30.           </section>  
  31.       </div>  
  32.   </div>  

CSS样式:

CSS Code复制内容到剪贴板

  1. body, h2, p {   
  2.  margin: 0;   
  3.  padding: 0;   
  4. }   
  5.   
  6. body {   
  7.  background: url("../images/cover.jpg") no-repeat;   
  8.  -webkit-background-size: cover;   
  9.     -moz-background-size: cover;   
  10.     -o-background-size: cover;   
  11.     background-size: cover;   
  12.  color: #333;   
  13.  font-family: Helvetica, sans-serif;   
  14.  text-align:center;   
  15. }   
  16. #shineflip {   
  17.  /*background: url("../images/cover.jpg") no-repeat;*/  
  18.  -o-background-size: 100% 100%;    
  19.  -webkit-background-size: 100% 100%;   
  20.  -moz-background-size: 100% 100%;   
  21.  background-size: 100% 100%;   
  22.  position: absolute;   
  23. }   
  24.   
  25. #shineflip-pages    
  26. {   
  27. /*    background-color:#fafafa;*/  
  28.     background-repeat: repeat;   
  29.     position: absolute;   
  30.     z-index: 2;   
  31. }   
  32.   
  33. #shineflip-pages section.cover_front, #shineflip-pages section.cover_background{   
  34.  position: absolute;   
  35.  overflow: hidden;   
  36.  color: #ffffff;   
  37. }   
  38.   
  39. #shineflip-pages .cover_front_content   
  40. {   
  41.  position: absolute;    
  42.  z-index: 1;   
  43.  overflow:hidden;   
  44.  whitewhite-space:nowrap;   
  45.  -ms-user-select:none;   
  46.  -webkit-user-select:none;   
  47.  -moz-user-select:none;   
  48. }   
  49.   
  50. #shineflip-pages .cover_front_back   
  51. {   
  52.  position: absolute;    
  53.  z-index: 0;   
  54. }   
  55.   
  56. #shineflip-pages .cover_background_content   
  57. {   
  58.  position: absolute;    
  59.  z-index: 1;   
  60.  overflow:hidden;   
  61.  whitewhite-space:nowrap;   
  62.  -ms-user-select:none;   
  63.  -webkit-user-select:none;   
  64.  -moz-user-select:none;   
  65. }   
  66.   
  67. #shineflip-pages .cover_background_back   
  68. {   
  69.  position: absolute;    
  70.  z-index: 0;   
  71. }   
  72.   
  73. #shineflip-pages section.pageflip    
  74. {   
  75.  display: block;   
  76.  position: absolute;   
  77.  overflow: hidden;   
  78. }   
  79.   
  80. #shineflip-pages section.page {   
  81.     //background-color: #fafafa;   
  82.  display: block;   
  83.  position: absolute;   
  84.  overflow: hidden;   
  85. }   
  86.  #shineflip-pages-flipcontent,#shineflip-pages section>div {   
  87.   display: block;   
  88.   font-size: 12px;   
  89.   position: absolute;   
  90.   overflow: hidden;   
  91.   width:100%;   
  92.   height:100%;   
  93.  }   
  94.  #shineflip-pages-flipcontent,#shineflip-pages section>span {   
  95.   display: block;   
  96.   font-size: 12px;   
  97.   position: absolute;   
  98.   overflow: hidden;   
  99.  }   
  100.  #shineflip-pages-flipcontent p,   
  101.  #shineflip-pages-flipcontent h2,   
  102.  #shineflip-pages section p,   
  103.  #shineflip-pages section h2 {   
  104.   line-height: 1.4em;   
  105.   text-align: justify;   
  106.  }   
  107.   
  108. #shineflip-canvas {   
  109.  position: absolute;   
  110.  z-index: 0;   
  111. }   
  112.   
  113. #shineflip-page-mid-canvas {   
  114.  position: absolute;   
  115.  pointer-events: none;   
  116.  z-index: 0;   
  117. }   

上述就是本文的整体内容,希望大家欣赏。

本文分享一款很酷的HTML5电子书翻页动画特效,这款HTML5翻页动画能够用鼠标拖动页面来效仿手动翻页的效...

先截三个图看看:

先截多少个图看看:

为大家推荐两款不错的多少个JQuery 音信头条淡入淡出效果代码,各位有亟待通晓的同班可进入参谋。

Mathew MacLean 提问

自个儿正在搜寻:

一种艺术为半个字符应用样式(在这种境况下,百分之五十的假名是晶莹的)。

本人当下一度查找并尝试的(不走运)

  • 渲染八分之四字符/字母的艺术
  • 用CSS或JavaScript渲染字符的一有个别
  • 对多个字符的四分之二用到CSS

以下是自己尝试达成的多少个例证:

澳门新萄京官方网站 2

本条是否有四个CSS或许JavaScript的消除方法存在,依旧本人必得选择图片的方法?小编不情愿利用图片的法子,因为文件将最终是动态变化的。

 

澳门新萄京官方网站 3

澳门新萄京官方网站 4

来自 Arbel 的最棒回答:(1280 赞)

澳门新萄京官方网站 5

澳门新萄京官方网站 6

代码

已做成贰个插件,放 Github 上了!

作用很准确啊?会不会误认为这一个字体是图片?那可不是图片,而是用JS完结的

效能很精确啊?会不会误感觉那一个字体是图形?那可不是图片,而是用JS实现的

 代码如下

演示 | 下载 Zip | Half-Style.com (重定向到GitHub)


  • 单个字符的纯css
  • JavaScript用来机关覆盖文本或多字符
  • 维护文本的可读性,盲人或视障职员使用的荧屏阅读器可甄别

在线演示

在线演示

复制代码

首先有的: 基本缓和方案

澳门新萄京官方网站 7

演示: 


这种办法用于别的动态文本或单个字符,何况都以机动适用的。全数你须要做的正是在对象文本上增加贰个class,剩下的就缓慢解决了。

再者,保留了初稿的可访问性,能够被盲人或视障人员使用的显示屏阅读器识别。

单个字符的贯彻

纯CSS。全体你必要做的正是把.halfStyle class用在各样你想要渲染十分之五样式字符的要素上。

对于每一个饱含字符的span成分,你能够增进二个data属性,譬喻data-content=”X”,何况在伪成分上选用content:attr(data-content);这样,.halfStyle:before class将会是动态的,你不需求为每一种实例举行硬编码

随机文本的落到实处

只需增加textTo哈尔fStyle class到含有文本的成分上。


CSS:

JavaScript

.halfStyle { position:relative; display:inline-block; font-size:80px; /* or any font size will work */ color: black; /* or transparent, any color */ overflow:hidden; white-space: pre; /* to preserve the spaces from collapsing */ } .halfStyle:before { display:block; z-index:1; position:absolute; top:0; left:0; width: 50%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; color: #f00; }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
.halfStyle {
    position:relative;
    display:inline-block;
    font-size:80px; /* or any font size will work */
    color: black; /* or transparent, any color */
    overflow:hidden;
    white-space: pre; /* to preserve the spaces from collapsing */
}
.halfStyle:before {
    display:block;
    z-index:1;
    position:absolute;
    top:0;
    left:0;
    width: 50%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    color: #f00;
}

HTML

JavaScript

<p>Single Characters:</p> <span class="halfStyle" data-content="X">X</span> <span class="halfStyle" data-content="Y">Y</span> <span class="halfStyle" data-content="Z">Z</span> <span class="halfStyle" data-content="A">A</span> <hr/> <p>Automated:</p> <span class="textToHalfStyle">Half-style, please.</span>

1
2
3
4
5
6
7
8
9
10
<p>Single Characters:</p>
<span class="halfStyle" data-content="X">X</span>
<span class="halfStyle" data-content="Y">Y</span>
<span class="halfStyle" data-content="Z">Z</span>
<span class="halfStyle" data-content="A">A</span>
 
<hr/>
<p>Automated:</p>
 
<span class="textToHalfStyle">Half-style, please.</span>

它会活动生效,只要增添 textToHalfStyle class到含有文本的要素上。

jQuery 自动形式:

JavaScript

jQuery(function($) { var text, chars, $el, i, output; // Iterate over all class occurences $('.textToHalfStyle').each(function(idx, el) { $el = $(el); text = $el.text(); chars = text.split(''); // Set the screen-reader text $el.html('<span style="position: absolute !important;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);">' text '</span>'); // Reset output for appending output = ''; // Iterate over all chars in the text for (i = 0; i < chars.length; i ) { // Create a styled element for each character and append to container output = '<span aria-hidden="true" data-content="' chars[i] '">' chars[i] '</span>'; } // Write to DOM only once $el.append(output); }); });

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
jQuery(function($) {
    var text, chars, $el, i, output;
 
    // Iterate over all class occurences
    $('.textToHalfStyle').each(function(idx, el) {
        $el = $(el);
        text = $el.text();
        chars = text.split('');
 
        // Set the screen-reader text
        $el.html('&lt;span style="position: absolute !important;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);"&gt;' text '&lt;/span&gt;');
 
        // Reset output for appending
        output = '';
 
        // Iterate over all chars in the text
        for (i = 0; i &lt; chars.length; i ) {
            // Create a styled element for each character and append to container
            output = '&lt;span aria-hidden="true" data-content="' chars[i] '"&gt;' chars[i] '&lt;/span&gt;';
        }
 
        // Write to DOM only once
        $el.append(output);
    });
});

演示: 


上边来轻松共享下完结进度及原理(网址中应用了jquery那些lib,大家这里就不再本身独立落成了,大家那边享受的也是jquery的落实方式):

上边来大致分享下完结进度及原理(网址中应用了jquery这些lib,我们那边就不再本人独立落成了,大家这里享用的也是jquery的落到实处况势):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ";
<html xmlns=";
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文书档案</title>
<script type='text/javascript' src='jquery-1.2.6.min.js'></script>
<style type="text/css">
#gallery1 {width:100%; overflow:hidden;}
#gallery1 a {position:relative; float:left; margin:5px;}
#gallery1 a span { display:none; background-image:url(zoom.png); background-repeat:no-repeat; width:48px; height:48px; position:absolute; left:15px; top:15px;}
#gallery1 img { border: solid 1px #999; padding:5px;}
#gallery1 a:hover span { display:block;}
 
#gallery2 {width:100%; overflow:hidden;}
#gallery2 a {position:relative; float:left; margin:5px;}
#gallery2 a span { display:none; background-image:url(zoom.png); background-repeat:no-repeat; width:48px; height:48px; position:absolute; left:15px; top:15px;}
#gallery2 img { border: solid 1px #999; padding:5px;}
 
</style>
<script>
$(document).ready(function(){
    $("#gallery2 a").append("<span></span>");
    $("#gallery2 a").hover(function(){
        $(this).children("span").fadeIn(600);
    },function(){
        $(this).children("span").fadeOut(200);
    });
});
</script>
</head>
<body>
<div id="gallery1">
    <h2>CSS solution</h2>
    <a href="1.jpg">
        <span></span>
        <img src="1.jpg" alt="" />
    </a>
    <a href="2.jpg">
        <span></span>
        <img src="2.jpg" alt="" />
    </a>
</div>
 
<div id="gallery2">
    <h2>jQuery solution</h2>
    <a href="1.jpg">
        <img src="1.jpg" alt="" />
    </a>
    <a href="2.jpg">
        <img src="2.jpg" alt="" />
    </a>
</div> 
</body>
</html>

第二有的:先进的缓慢解决方案-独立的左侧和左边

澳门新萄京官方网站 8

运用这种办法你能够分级独立的渲染右边和左边部分。

一切都以同样的,只是更加高档的CSS在发挥功能。

演示: 

JavaScript

.halfStyle { position:relative; display:inline-block; font-size:80px; /* or any font size will work */ color: transparent; /* hide the base character */ overflow:hidden; white-space: pre; /* to preserve the spaces from collapsing */ } .halfStyle:before { /* creates the left part */ display:block; z-index:1; position:absolute; top:0; width: 50%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; pointer-events: none; /* so the base char is selectable by mouse */ color: #f00; /* for demo purposes */ text-shadow: 2px -2px 0px #af0; /* for demo purposes */ } .halfStyle:after { /* creates the right part */ display:block; direction: rtl; /* very important, will make the width to start from right */ position:absolute; z-index:2; top:0; left:50%; width: 50%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; pointer-events: none; /* so the base char is selectable by mouse */ color: #000; /* for demo purposes */ text-shadow: 2px 2px 0px #0af; /* for demo purposes */ }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
.halfStyle {
    position:relative;
    display:inline-block;
    font-size:80px; /* or any font size will work */
    color: transparent; /* hide the base character */
    overflow:hidden;
    white-space: pre; /* to preserve the spaces from collapsing */
}
.halfStyle:before { /* creates the left part */
    display:block;
    z-index:1;
    position:absolute;
    top:0;
    width: 50%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    pointer-events: none; /* so the base char is selectable by mouse */
    color: #f00; /* for demo purposes */
    text-shadow: 2px -2px 0px #af0; /* for demo purposes */
}
.halfStyle:after { /* creates the right part */
    display:block;
    direction: rtl; /* very important, will make the width to start from right */
    position:absolute;
    z-index:2;
    top:0;
    left:50%;
    width: 50%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    pointer-events: none; /* so the base char is selectable by mouse */
    color: #000; /* for demo purposes */
    text-shadow: 2px 2px 0px #0af; /* for demo purposes */
}


HTML代码:

HTML代码:

例2

其三有的:混合-相称和革新

今昔大家知晓什么样是或者的,让大家来增添一些花样。


复制代码 代码如下:

复制代码 代码如下:

 代码如下

-水平八分之四

澳门新萄京官方网站 9

Demo

JavaScript

.halfStyle { position:relative; display:inline-block; font-size:80px; /* or any font size will work */ color: transparent; /* hide the base character */ overflow:hidden; white-space: pre; /* to preserve the spaces from collapsing */ } .halfStyle:before { /* creates the top part */ display:block; z-index:2; position:absolute; top:0; height: 50%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; pointer-events: none; /* so the base char is selectable by mouse */ color: #f00; /* for demo purposes */ text-shadow: 2px -2px 0px #af0; /* for demo purposes */ } .halfStyle:after { /* creates the bottom part */ display:block; position:absolute; z-index:1; top:0; height: 100%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; pointer-events: none; /* so the base char is selectable by mouse */ color: #000; /* for demo purposes */ text-shadow: 2px 2px 0px #0af; /* for demo purposes */ }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
.halfStyle {
    position:relative;
    display:inline-block;
    font-size:80px; /* or any font size will work */
    color: transparent; /* hide the base character */
    overflow:hidden;
    white-space: pre; /* to preserve the spaces from collapsing */
}
.halfStyle:before { /* creates the top part */
    display:block;
    z-index:2;
    position:absolute;
    top:0;
    height: 50%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    pointer-events: none; /* so the base char is selectable by mouse */
    color: #f00; /* for demo purposes */
    text-shadow: 2px -2px 0px #af0; /* for demo purposes */
}
.halfStyle:after { /* creates the bottom part */
    display:block;
    position:absolute;
    z-index:1;
    top:0;
    height: 100%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    pointer-events: none; /* so the base char is selectable by mouse */
    color: #000; /* for demo purposes */
    text-shadow: 2px 2px 0px #0af; /* for demo purposes */
}


<span class="rainbows">© 2009 Dragon Interactive. All Rights Reserved.</span>

<span class="rainbows">© 2009 Dragon Interactive. All Rights Reserved.</span>

复制代码

-垂直1/3

澳门新萄京官方网站 10

Demo

JavaScript

.halfStyle { /* base char and also the right 1/3 */ position:relative; display:inline-block; font-size:80px; /* or any font size will work */ color: transparent; /* hide the base character */ overflow:hidden; white-space: pre; /* to preserve the spaces from collapsing */ color: #f0f; /* for demo purposes */ text-shadow: 2px 2px 0px #0af; /* for demo purposes */ } .halfStyle:before { /* creates the left 1/3 */ display:block; z-index:2; position:absolute; top:0; width: 33.33%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; pointer-events: none; /* so the base char is selectable by mouse */ color: #f00; /* for demo purposes */ text-shadow: 2px -2px 0px #af0; /* for demo purposes */ } .halfStyle:after { /* creates the middle 1/3 */ display:block; z-index:1; position:absolute; top:0; width: 66.66%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; pointer-events: none; /* so the base char is selectable by mouse */ color: #000; /* for demo purposes */ text-shadow: 2px 2px 0px #af0; /* for demo purposes */ }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
.halfStyle { /* base char and also the right 1/3 */
    position:relative;
    display:inline-block;
    font-size:80px; /* or any font size will work */
    color: transparent; /* hide the base character */
    overflow:hidden;
    white-space: pre; /* to preserve the spaces from collapsing */
    color: #f0f; /* for demo purposes */
    text-shadow: 2px 2px 0px #0af; /* for demo purposes */
}
.halfStyle:before { /* creates the left 1/3 */
    display:block;
    z-index:2;
    position:absolute;
    top:0;
    width: 33.33%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    pointer-events: none; /* so the base char is selectable by mouse */
    color: #f00; /* for demo purposes */
    text-shadow: 2px -2px 0px #af0; /* for demo purposes */
}
.halfStyle:after { /* creates the middle 1/3 */
    display:block;
    z-index:1;
    position:absolute;
    top:0;
    width: 66.66%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    pointer-events: none; /* so the base char is selectable by mouse */
    color: #000; /* for demo purposes */
    text-shadow: 2px 2px 0px #af0; /* for demo purposes */
}


为了便于代码重用,大家由此class来标记出什么样文字供给充实那几个特效,这里用的是rainbows。

为了有帮忙代码重用,大家通过class来标记出怎么着文字须求充实这么些特效,这里用的是rainbows。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ";
<html xmlns=";
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<style>
a { color:#CCCCCC}
li { list-style:none;}
span { padding-right:20px; color:#FFFFFF; font-weight:bold;}
</style>
</head>
<body>
<div id="ticker" style="padding:10px; background:#333333">
        <!-- START TICKER VER 1.0.1 -->
<script src="" type="text/javascript"></script>
<script type="text/javascript">
/* =========================================================
// jquery.innerfade.js
// Datum: 2008-02-14
// Firma: Medienfreunde Hofmann & Baldes GbR
// Author: Torsten Baldes
// Mail: [email protected]
// Web:
// based on the work of Matt Oakes
// and Ralf S. Engelschall
*
*  <ul id="news">
*      <li>content 1</li>
*      <li>content 2</li>
*      <li>content 3</li>
*  </ul>
*
*  $('#news').innerfade({
*      animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'),
*      speed: Fading-/Sliding-Speed in milliseconds or keywords (slow, normal or fast) (Default: 'normal'),
*      timeout: Time between the fades in milliseconds (Default: '2000'),
*      type: Type of slideshow: 'sequence', 'random' or 'random_start' (Default: 'sequence'),
*         containerheight: Height of the containing element in any css-height-value (Default: 'auto'),
*      runningclass: CSS-Class which the container get’s applied (Default: 'innerfade'),
*      children: optional children selector (Default: null)
*  });
*
// ========================================================= */
(function($) {
    $.fn.innerfade = function(options) {
        return this.each(function() {
            $.innerfade(this, options);
        });
    };
    $.innerfade = function(container, options) {
        var settings = {
                'animationtype':    'fade',
            'speed':            'normal',
            'type':             'sequence',
            'timeout':          2000,
            'containerheight':  'auto',
            'runningclass':     'innerfade',
            'children':         null
        };
        if (options)
            $.extend(settings, options);
        if (settings.children === null)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);
        if (elements.length > 1) {
            $(container).css('position', 'relative').css('height', settings.containerheight).addClass(settings.runningclass);
            for (var i = 0; i < elements.length; i ) {
                $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
            };
            if (settings.type == "sequence") {
                setTimeout(function() {
                    $.innerfade.next(elements, settings, 1, 0);
                }, settings.timeout);
                $(elements[0]).show();
            } else if (settings.type == "random") {
                    var last = Math.floor ( Math.random () * ( elements.length ) );
                setTimeout(function() {
                    do {
                                                current = Math.floor ( Math.random ( ) * ( elements.length ) );
                                        } while (last == current );
                                        $.innerfade.next(elements, settings, current, last);
                }, settings.timeout);
                $(elements[last]).show();
                        } else if ( settings.type == 'random_start' ) {
                                settings.type = 'sequence';
                                var current = Math.floor ( Math.random () * ( elements.length ) );
                                setTimeout(function(){
                                    $.innerfade.next(elements, settings, (current 1) %  elements.length, current);
                                }, settings.timeout);
                                $(elements[current]).show();
                        }    else {
                            alert('Innerfade-Type must either be 'sequence', 'random' or 'random_start'');
                        }
                }
    };
    $.innerfade.next = function(elements, settings, current, last) {
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
                            removeFilter($(this)[0]);
                        });
        } else
            alert('Innerfade-animationtype must either be 'slide' or 'fade'');
        if (settings.type == "sequence") {
            if ((current 1) < elements.length) {
                current = current 1;
                last = current - 1;
            } else {
                current = 0;
                last = elements.length - 1;
            }
        } else if (settings.type == "random") {
            last = current;
            while (current == last)
                current = Math.floor(Math.random() * elements.length);
        } else
            alert('Innerfade-Type must either be 'sequence', 'random' or 'random_start'');
        setTimeout((function() {
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };
})(jQuery);
// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
    if(element.style.removeAttribute){
        element.style.removeAttribute('filter');
    }
}
</script>
<script type="text/javascript">
  jQuery.noConflict();
  // Use jQuery via jQuery(...)
     jQuery(document).ready(function(){
    jQuery('#news').innerfade({
                         speed: '1',
                         timeout: 2000,
                         containerheight: 20,
                         animationtype: 'fade'
      });
    });
  </script>
        <ul id="news" style="overflow: hidden; display:block; margin:0; clear:both">
          <li style="z-index: 5; position: absolute; display: none;"><span>HOT NEWS</span><a href="#">Racing has begun at the 2009 AllegroCup Windsurfing Championship in ?eba, Poland. This event, organised by... </a></li>
          <li style="z-index: 4; position: absolute; display: none;"><span>HOT NEWS</span><a href="#">Sean is currently racing at the Euro-Challenger FW Event in Pobierowo, Poland. A small seaside town on the... </a></li>
          <li style="z-index: 3; position: absolute; display: list-item;"><span>HOT NEWS</span><a href="#">Sean will be joining the dark side of windsurfing this season, on the International Team for Point-7 sails.... </a></li>
          <li style="z-index: 2; position: absolute; display: none;"><span>HOT NEWS</span><a href="#">Sean's all new website for 2009 launched today! Stay tuned for features on many CSS galleries once more. The... </a></li>
          <li style="z-index: 1; position: absolute; display: none;"><span>HOT NEWS</span><a href="#">Sean has just arrived in Europe and settled in to his training-base in the Netherlands, preparing for this... </a></li>
        </ul>
        <!-- END TICKER -->
      </div>
</body>
</html>

-水平 1/3

澳门新萄京官方网站 11

Demo

JavaScript

.halfStyle { /* base char and also the bottom 1/3 */ position:relative; display:inline-block; font-size:80px; /* or any font size will work */ color: transparent; overflow:hidden; white-space: pre; /* to preserve the spaces from collapsing */ color: #f0f; text-shadow: 2px 2px 0px #0af; /* for demo purposes */ } .halfStyle:before { /* creates the top 1/3 */ display:block; z-index:2; position:absolute; top:0; height: 33.33%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; pointer-events: none; /* so the base char is selectable by mouse */ color: #f00; /* for demo purposes */ text-shadow: 2px -2px 0px #fa0; /* for demo purposes */ } .halfStyle:after { /* creates the middle 1/3 */ display:block; position:absolute; z-index:1; top:0; height: 66.66%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; pointer-events: none; /* so the base char is selectable by mouse */ color: #000; /* for demo purposes */ text-shadow: 2px 2px 0px #af0; /* for demo purposes */ }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
.halfStyle { /* base char and also the bottom 1/3 */
    position:relative;
    display:inline-block;
    font-size:80px; /* or any font size will work */
    color: transparent;
    overflow:hidden;
    white-space: pre; /* to preserve the spaces from collapsing */
    color: #f0f;
    text-shadow: 2px 2px 0px #0af; /* for demo purposes */
}
.halfStyle:before { /* creates the top 1/3 */
    display:block;
    z-index:2;
    position:absolute;
    top:0;
    height: 33.33%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    pointer-events: none; /* so the base char is selectable by mouse */
    color: #f00; /* for demo purposes */
    text-shadow: 2px -2px 0px #fa0; /* for demo purposes */
}
.halfStyle:after { /* creates the middle 1/3 */
    display:block;
    position:absolute;
    z-index:1;
    top:0;
    height: 66.66%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    pointer-events: none; /* so the base char is selectable by mouse */
    color: #000; /* for demo purposes */
    text-shadow: 2px 2px 0px #af0; /* for demo purposes */
}


CSS代码:

CSS代码:

新闻头条淡入淡出效果代码,各位有需求驾驭的同桌可步入参考。 例 代码 代码如下 复制代码 !DOCTYPE html...

-HalfStyle改进 @KevinGranger

澳门新萄京官方网站 12

DEMO

JavaScript

body{ background-color: black; } .textToHalfStyle{ display:block; margin: 200px 0 0 0; text-align:center; } .halfStyle { font-family: 'Libre Baskerville', serif; position:relative; display:inline-block; width:1; font-size:70px; color: black; overflow:hidden; white-space: pre; text-shadow: 1px 2px 0 white; } .halfStyle:before { display:block; z-index:1; position:absolute; top:0; width: 50%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; color: white; }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
body{
    background-color: black;
}
 
.textToHalfStyle{
    display:block;
    margin: 200px 0 0 0;
    text-align:center;
}
 
.halfStyle {
    font-family: 'Libre Baskerville', serif;
    position:relative;
    display:inline-block;
    width:1;
    font-size:70px;
    color: black;
    overflow:hidden;
    white-space: pre;
    text-shadow: 1px 2px 0 white;
}
.halfStyle:before {
    display:block;
    z-index:1;
    position:absolute;
    top:0;
    width: 50%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    color: white;
}


复制代码 代码如下:

复制代码 代码如下:

 -PeelingStyle 改进的 HalfStyle @SamTremaine

澳门新萄京官方网站 13

.rainbows{position:relative;display:block;} .rainbow { background: transparent; display: block; position: relative; height: 1px; overflow: hidden; z-index: 5; } .rainbow span { position: absolute; display: block; top: 0; left: 0px; } .rainbows .highlight { color: #fff; display:block; position: absolute; top: -2px; left: 0px; z-index: 4; } .rainbows .shadow { color: #000; display:block; position: absolute; opacity: 0.5; filter:alpha(opacity=50); top: 2px; left: 2px; z-index: 3; }.rainbows{position:relative;display:block;}
.rainbow {
background: transparent;
display: block;
position: relative;
height: 1px;
overflow: hidden;
z-index: 5;
}

.rainbows{position:relative;display:block;} .rainbow { background: transparent; display: block; position: relative; height: 1px; overflow: hidden; z-index: 5; } .rainbow span { position: absolute; display: block; top: 0; left: 0px; } .rainbows .highlight { color: #fff; display:block; position: absolute; top: -2px; left: 0px; z-index: 4; } .rainbows .shadow { color: #000; display:block; position: absolute; opacity: 0.5; filter:alpha(opacity=50); top: 2px; left: 2px; z-index: 3; }.rainbows{position:relative;display:block;}
.rainbow {
background: transparent;
display: block;
position: relative;
height: 1px;
overflow: hidden;
z-index: 5;
}

Demo and on samtremaine.co.uk

演示 和 samtremaine.co.uk

JavaScript

.halfStyle { position: relative; display: inline-block; font-size: 68px; color: rgba(0, 0, 0, 0.8); overflow: hidden; white-space: pre; transform: rotate(4deg); text-shadow: 2px 1px 3px rgba(0, 0, 0, 0.3); } .halfStyle:before { /* creates the left part */ display: block; z-index: 1; position: absolute; top: -0.5px; left: -3px; width: 100%; content: attr(data-content); overflow: hidden; pointer-events: none; color: #FFF; transform: rotate(-4deg); text-shadow: 0px 0px 1px #000; }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
.halfStyle {
    position: relative;
    display: inline-block;
    font-size: 68px;
    color: rgba(0, 0, 0, 0.8);
    overflow: hidden;
    white-space: pre;
    transform: rotate(4deg);
    text-shadow: 2px 1px 3px rgba(0, 0, 0, 0.3);
}
.halfStyle:before { /* creates the left part */
    display: block;
    z-index: 1;
    position: absolute;
    top: -0.5px;
    left: -3px;
    width: 100%;
    content: attr(data-content);
    overflow: hidden;
    pointer-events: none;
    color: #FFF;
    transform: rotate(-4deg);
    text-shadow: 0px 0px 1px #000;
}


.rainbow span {
position: absolute;
display: block;
top: 0;
left: 0px;
}

.rainbow span {
position: absolute;
display: block;
top: 0;
left: 0px;
}

第3局地:筹划生育

定制不一致的Half-Style样式集能够用在同贰个页面包车型客车所需成分上。你能够定义两个样式集并告诉插件要用哪八个。

插件在目的.textTo哈尔fStyle成分上行使data属性data-halfstyle=”[-CustomClassName-]”,全数都会活动退换。

所以,只要含有文本的要素增添了textToHalfStyle class和data属性 data-halfstyle="[-CustomClassName-]",插件将完成剩下的工作。

澳门新萄京官方网站 14

同样页面中五个Half-Styles的 演示

JavaScript

jQuery(function($) { var halfstyle_text, halfstyle_chars, $halfstyle_el, halfstyle_i, halfstyle_output, halfstyle_style; // Iterate over all class occurrences $('.textToHalfStyle').each(function(idx, halfstyle_el) { $halfstyle_el = $(halfstyle_SO销路好问答,音信头条淡入淡出效果。el); halfstyle_style = $halfstyle_el.data('halfstyle'); halfstyle_text = $halfstyle_el.text(); halfstyle_chars = halfstyle_text.split(''); // Set the screen-reader text $halfstyle_el.html('<span style="position: absolute !important;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);">' halfstyle_text '</span>'); // Reset output for appending halfstyle_output = ''; // Iterate over all chars in the text for (halfstyle_i = 0; halfstyle_i < halfstyle_chars.length; halfstyle_i ) { // Create a styled element for each character and append to container halfstyle_output = '<span aria-hidden="true" data-content="' halfstyle_chars[halfstyle_i] '">' halfstyle_chars[halfstyle_i] '</span>'; } // Write to DOM only once $halfstyle_el.append(halfstyle_output); }); });

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
jQuery(function($) {
    var halfstyle_text, halfstyle_chars, $halfstyle_el, halfstyle_i, halfstyle_output, halfstyle_style;
 
    // Iterate over all class occurrences
    $('.textToHalfStyle').each(function(idx, halfstyle_el) {
        $halfstyle_el = $(halfstyle_el);
        halfstyle_style = $halfstyle_el.data('halfstyle');
        halfstyle_text = $halfstyle_el.text();
        halfstyle_chars = halfstyle_text.split('');
 
        // Set the screen-reader text
        $halfstyle_el.html('&lt;span style="position: absolute !important;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);"&gt;' halfstyle_text '&lt;/span&gt;');
 
        // Reset output for appending
        halfstyle_output = '';
 
        // Iterate over all chars in the text
        for (halfstyle_i = 0; halfstyle_i &lt; halfstyle_chars.length; halfstyle_i ) {
            // Create a styled element for each character and append to container
            halfstyle_output = '&lt;span aria-hidden="true" data-content="' halfstyle_chars[halfstyle_i] '"&gt;' halfstyle_chars[halfstyle_i] '&lt;/span&gt;';
        }
 
        // Write to DOM only once
        $halfstyle_el.append(halfstyle_output);
    });
});

除此以外,CSS样式集class的概念相称上述的 [-CustomClassName-] 部分,何况链到.halfStyle,由此大家将有.halfStyle.[-CustomClassName-]

JavaScript

/* start half-style hs-base */ .halfStyle.hs-base { position:relative; display:inline-block; font-size:80px; /* or any font size will work */ overflow:hidden; white-space: pre; /* to preserve the spaces from collapsing */ color: #000; /* for demo purposes */ } .halfStyle.hs-base:before { display:block; z-index:1; position:absolute; top:0; width: 50%; content: attr(data-content); /* dynamic content for the pseudo element */ pointer-events: none; /* so the base char is selectable by mouse */ overflow:hidden; color: #f00; /* for demo purposes */ } /* end half-style hs-base */ /* start half-style hs-horizontal-third */ .halfStyle.hs-horizontal-third { /* base char and also the bottom 1/3 */ position:relative; display:inline-block; font-size:80px; /* or any font size will work */ color: transparent; overflow:hidden; white-space: pre; /* to preserve the spaces from collapsing */ color: #f0f; text-shadow: 2px 2px 0px #0af; /* for demo purposes */ } .halfStyle.hs-horizontal-third:before { /* creates the top 1/3 */ display:block; z-index:2; position:absolute; top:0; height: 33.33%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; pointer-events: none; /* so the base char is selectable by mouse */ color: #f00; /* for demo purposes */ text-shadow: 2px -2px 0px #fa0; /* for demo purposes */ } .halfStyle.hs-horizontal-third:after { /* creates the middle 1/3 */ display:block; position:absolute; z-index:1; top:0; height: 66.66%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; pointer-events: none; /* so the base char is selectable by mouse */ color: #000; /* for demo purposes */ text-shadow: 2px 2px 0px #af0; /* for demo purposes */ } /* end half-style hs-horizontal-third */ /* start half-style hs-PeelingStyle, by user SamTremaine on Stackoverflow.com */ .halfStyle.hs-PeelingStyle { position: relative; display: inline-block; font-size: 68px; color: rgba(0, 0, 0, 0.8); overflow: hidden; white-space: pre; transform: rotate(4deg); text-shadow: 2px 1px 3px rgba(0, 0, 0, 0.3); } .halfStyle.hs-PeelingStyle:before { /* creates the left part */ display: block; z-index: 1; position: absolute; top: -0.5px; left: -3px; width: 100%; content: attr(data-content); overflow: hidden; pointer-events: none; color: #FFF; transform: rotate(-4deg); text-shadow: 0px 0px 1px #000; } /* end half-style hs-PeelingStyle */ /* start half-style hs-KevinGranger, by user KevinGranger on StackOverflow.com*/ .textToHalfStyle.hs-KevinGranger { display:block; margin: 200px 0 0 0; text-align:center; } .halfStyle.hs-KevinGranger { font-family: 'Libre Baskerville', serif; position:relative; display:inline-block; width:1; font-size:70px; color: black; overflow:hidden; white-space: pre; text-shadow: 1px 2px 0 white; } .halfStyle.hs-KevinGranger:before { display:block; z-index:1; position:absolute; top:0; width: 50%; content: attr(data-content); /* dynamic content for the pseudo element */ overflow:hidden; color: white; } /* end half-style hs-KevinGranger

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* start half-style hs-base */
.halfStyle.hs-base {
    position:relative;
    display:inline-block;
    font-size:80px; /* or any font size will work */
    overflow:hidden;
    white-space: pre; /* to preserve the spaces from collapsing */
    color: #000; /* for demo purposes */
}
.halfStyle.hs-base:before {
    display:block;
    z-index:1;
    position:absolute;
    top:0;
    width: 50%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    pointer-events: none; /* so the base char is selectable by mouse */
    overflow:hidden;
    color: #f00; /* for demo purposes */
}
/* end half-style hs-base */
 
/* start half-style hs-horizontal-third */
.halfStyle.hs-horizontal-third { /* base char and also the bottom 1/3 */
    position:relative;
    display:inline-block;
    font-size:80px; /* or any font size will work */
    color: transparent;
    overflow:hidden;
    white-space: pre; /* to preserve the spaces from collapsing */
    color: #f0f;
    text-shadow: 2px 2px 0px #0af; /* for demo purposes */
}
.halfStyle.hs-horizontal-third:before { /* creates the top 1/3 */
    display:block;
    z-index:2;
    position:absolute;
    top:0;
    height: 33.33%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    pointer-events: none; /* so the base char is selectable by mouse */
    color: #f00; /* for demo purposes */
    text-shadow: 2px -2px 0px #fa0; /* for demo purposes */
}
.halfStyle.hs-horizontal-third:after { /* creates the middle 1/3 */
    display:block;
    position:absolute;
    z-index:1;
    top:0;
    height: 66.66%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    pointer-events: none; /* so the base char is selectable by mouse */
    color: #000; /* for demo purposes */
    text-shadow: 2px 2px 0px #af0; /* for demo purposes */
}
/* end half-style hs-horizontal-third */
 
/* start half-style hs-PeelingStyle, by user SamTremaine on Stackoverflow.com */
.halfStyle.hs-PeelingStyle {
    position: relative;
    display: inline-block;
    font-size: 68px;
    color: rgba(0, 0, 0, 0.8);
    overflow: hidden;
    white-space: pre;
    transform: rotate(4deg);
    text-shadow: 2px 1px 3px rgba(0, 0, 0, 0.3);
}
.halfStyle.hs-PeelingStyle:before { /* creates the left part */
    display: block;
    z-index: 1;
    position: absolute;
    top: -0.5px;
    left: -3px;
    width: 100%;
    content: attr(data-content);
    overflow: hidden;
    pointer-events: none;
    color: #FFF;
    transform: rotate(-4deg);
    text-shadow: 0px 0px 1px #000;
}
/* end half-style hs-PeelingStyle */
 
/* start half-style hs-KevinGranger, by user KevinGranger on StackOverflow.com*/
.textToHalfStyle.hs-KevinGranger {
    display:block;
    margin: 200px 0 0 0;
    text-align:center;
}
 
.halfStyle.hs-KevinGranger {
    font-family: 'Libre Baskerville', serif;
    position:relative;
    display:inline-block;
    width:1;
    font-size:70px;
    color: black;
    overflow:hidden;
    white-space: pre;
    text-shadow: 1px 2px 0 white;
}
.halfStyle.hs-KevinGranger:before {
    display:block;
    z-index:1;
    position:absolute;
    top:0;
    width: 50%;
    content: attr(data-content); /* dynamic content for the pseudo element */
    overflow:hidden;
    color: white;
}
/* end half-style hs-KevinGranger

HTML:

JavaScript

<p> <span class="textToHalfStyle" data-halfstyle="hs-base">Half-style, please.</span> </p> <p> <span class="textToHalfStyle" data-halfstyle="hs-horizontal-third">Half-style, please.</span> </p> <p> <span class="textToHalfStyle" data-halfstyle="hs-PeelingStyle">Half-style, please.</span> </p> <p style="background-color:#000;"> <span class="textToHalfStyle" data-halfstyle="hs-KevinGranger">Half-style, please.</span> </p>

1
2
3
4
5
6
7
8
9
10
11
12
<p>
    <span class="textToHalfStyle" data-halfstyle="hs-base">Half-style, please.</span>
</p>
<p>
    <span class="textToHalfStyle" data-halfstyle="hs-horizontal-third">Half-style, please.</span>
</p>
<p>
    <span class="textToHalfStyle" data-halfstyle="hs-PeelingStyle">Half-style, please.</span>
</p>
<p style="background-color:#000;">
    <span class="textToHalfStyle" data-halfstyle="hs-KevinGranger">Half-style, please.</span>
</p>

一样页面中几个Half-Styles的 演示

赞 收藏 评论

.rainbows .highlight {
color: #fff;
display:block;
position: absolute;
top: -2px;
left: 0px;
z-index: 4;
}

.rainbows .highlight {
color: #fff;
display:block;
position: absolute;
top: -2px;
left: 0px;
z-index: 4;
}

至于笔者:Carman

澳门新萄京官方网站 15

(和讯今日头条:@常见长剑) 个人主页 · 作者的篇章

澳门新萄京官方网站 16

.rainbows .shadow {
color: #000;
display:block;
position: absolute;
opacity: 0.5;
filter:alpha(opacity=50);
top: 2px;
left: 2px;
z-index: 3;
}

.rainbows .shadow {
color: #000;
display:block;
position: absolute;
opacity: 0.5;
filter:alpha(opacity=50);
top: 2px;
left: 2px;
z-index: 3;
}

此间关键表明下highlight和shadow那多少个class的含义,其实从字面也基本得以知晓,那多个class是为着扩充字体的立体性而设定,三个是暗绛红的高亮,多个是苹果绿阴影。

此地关键表达下highlight和shadow那三个class的含义,其实从字面也基本得以驾驭,那七个class是为着增添字体的立体性而设定,八个是反革命的高亮,二个是玛瑙红阴影。

JS部分:

JS部分:

复制代码 代码如下:

复制代码 代码如下:

function initGradients(s) { $(function() { $(s).each(function() { var el = this; var from = $(el).attr('gradFromColor')||'#ffffff', to = $(el).attr('gradToColor')||'#000000'; var fR = parseInt(from.substring(1, 3), 16), fG = parseInt(from.substring(3, 5), 16), fB = parseInt(from.substring(5, 7), 16), tR = parseInt(to.substring(1, 3), 16), tG = parseInt(to.substring(3, 5), 16), tB = parseInt(to.substring(5, 7), 16); var h = $(this).height() * 1.5; var html,cacheHTML=[]; this.initHTML = html = this.initHTML||this.innerHTML; this.innerHTML = ''; for (var i = 0; i < h; i ) { var c = '#' (Math.floor(fR * (h - i) / h tR * (i / h))).toString(16) (Math.floor(fG * (h - i) / h tG * (i / h))).toString(16) (Math.floor(fB * (h - i) / h tB * (i / h))).toString(16); cacheHTML.push('<span class="rainbow rainbow-' i

function initGradients(s) { $(function() { $(s).each(function() { var el = this; var from = $(el).attr('gradFromColor')||'#ffffff', to = $(el).attr('gradToColor')||'#000000'; var fR = parseInt(from.substring(1, 3), 16), fG = parseInt(from.substring(3, 5), 16), fB = parseInt(from.substring(5, 7), 16), tR = parseInt(to.substring(1, 3), 16), tG = parseInt(to.substring(3, 5), 16), tB = parseInt(to.substring(5, 7), 16); var h = $(this).height() * 1.5; var html,cacheHTML=[]; this.initHTML = html = this.initHTML||this.innerHTML; this.innerHTML = ''; for (var i = 0; i < h; i ) { var c = '#' (Math.floor(fR * (h - i) / h tR * (i / h))).toString(16) (Math.floor(fG * (h - i) / h tG * (i / h))).toString(16) (Math.floor(fB * (h - i) / h tB * (i / h))).toString(16); cacheHTML.push('<span class="rainbow rainbow-' i

  • '" style="color: ' c ';"><span style="top: ' ( - i - 1) 'px;">' html '</span></span>') } cacheHTML.push('<span class="highlight">' html '</span>','<span class="shadow">' html '</span>'); $(cacheHTML.join('')).appendTo(this) }) }) } //这几个片段就是调用了,传入要增多效果的成分,这里能够是jquery的妄动接纳符。 initGradients('.rainbows'); function initGradients(s) {
    $(function() {
    $(s).each(function() {
    var el = this;
    var from = $(el).attr('gradFromColor')||'#ffffff', to = $(el).attr('gradToColor')||'#000000';
    var fR = parseInt(from.substring(1, 3), 16),
    fG = parseInt(from.substring(3, 5), 16),
    fB = parseInt(from.substring(5, 7), 16),
    tR = parseInt(to.substring(1, 3), 16),
    tG = parseInt(to.substring(3, 5), 16),
    tB = parseInt(to.substring(5, 7), 16);
  • '" style="color: ' c ';"><span style="top: ' ( - i - 1) 'px;">' html '</span></span>') } cacheHTML.push('<span class="highlight">' html '</span>','<span class="shadow">' html '</span>'); $(cacheHTML.join('')).appendTo(this) }) }) } //这么些片段正是调用了,传入要增添效果的因素,这里可以是jquery的自由选用符。 initGradients('.rainbows'); function initGradients(s) {
    $(function() {
    $(s).each(function() {
    var el = this;
    var from = $(el).attr('gradFromColor')||'#ffffff', to = $(el).attr('gradToColor')||'#000000';
    var fR = parseInt(from.substring(1, 3), 16),
    fG = parseInt(from.substring(3, 5), 16),
    fB = parseInt(from.substring(5, 7), 16),
    tR = parseInt(to.substring(1, 3), 16),
    tG = parseInt(to.substring(3, 5), 16),
    tB = parseInt(to.substring(5, 7), 16);

var h = $(this).height() * 1.5;
var html,cacheHTML=[];
this.initHTML = html = this.initHTML||this.innerHTML;
this.innerHTML = '';
for (var i = 0; i < h; i ) {
var c = '#' (Math.floor(fR * (h - i) / h tR * (i / h))).toString(16) (Math.floor(fG * (h - i) / h tG * (i / h))).toString(16) (Math.floor(fB * (h - i) / h tB * (i / h))).toString(16);
cacheHTML.push('<span class="rainbow rainbow-' i '" style="color: ' c ';"><span style="top: ' ( - i - 1) 'px;">' html '</span></span>')
}
cacheHTML.push('<span class="highlight">' html '</span>','<span class="shadow">' html '</span>');
$(cacheHTML.join('')).appendTo(this)
})
})
}
//那些有个别正是调用了,传入要增加效果的要素,这里能够是jquery的随机选用符。
initGradients('.rainbows');

var h = $(this).height() * 1.5;
var html,cacheHTML=[];
this.initHTML = html = this.initHTML||this.innerHTML;
this.innerHTML = '';
for (var i = 0; i < h; i ) {
var c = '#' (Math.floor(fR * (h - i) / h tR * (i / h))).toString(16) (Math.floor(fG * (h - i) / h tG * (i / h))).toString(16) (Math.floor(fB * (h - i) / h tB * (i / h))).toString(16);
cacheHTML.push('<span class="rainbow rainbow-' i '" style="color: ' c ';"><span style="top: ' ( - i - 1) 'px;">' html '</span></span>')
}
cacheHTML.push('<span class="highlight">' html '</span>','<span class="shadow">' html '</span>');
$(cacheHTML.join('')).appendTo(this)
})
})
}
//那几个片段正是调用了,传入要增加效果的因素,这里能够是jquery的自由采取符。
initGradients('.rainbows');

代码看起来并不算多,然则即使想知道原理的话依旧要认真的理解下那些代码的。

代码看起来并不算多,不过假使想通晓原理的话照旧要认真的知晓下这一个代码的。

结合JS/CSS我们能够观察其大意的思路如下:

组成JS/CSS大家可以看来其大约的思绪如下:

程序首先算出字体所在容器的中度N,然后清空容器内容,并加多N个span,每一种span内容都为原容器的文字,各个span的颜色依照渐变色举办总计,何况里面包车型地铁文字定位都比较在此之前三个span的文字向上偏移贰个像素。CSS中能够看出,各类span的莫斯科大学都为1。那样,我们就通过N各区别颜色的1px的span把字体“拼”出来了,然后加上“高光/阴影”就消除。

次第首先算出字体所在容器的高度N,然后清空容器内容,并增加N个span,各样span内容都为原容器的文字,各种span的颜料依据渐变色举办总计,并且里面包车型客车文字定位都比较此前三个span的文字向上偏移多个像素。CSS中能够观察,每一个span的莫斯中国科学技术大学学都为1。这样,大家就由此N各不一样颜色的1px的span把字体“拼”出来了,然后加上“干眼/阴影”就解决。

基于jQuery的立体文字渐变效果

依靠jQuery的立体文字渐变效果

你或然感兴趣的篇章:

  • jQuery获得字体颜色16个人码的法门
  • jquery实现实时改换网页字体大小、字体背景象和颜料的艺术
  • 澳门新萄京官方网站,JQuery完结动态及时改动字体颜色的方法
  • jQuery达成的背景颜色渐变动画功用示例
  • jQuery与js完结颜色渐变的诀窍
  • jQuery完结的文字hover颜色渐变效果实例
  • 基于jquery的direction图片渐变动画作用
  • jQuery 营造动态渐变按键详细图像和文字化教育程
  • jQuery渐变发光导航菜单的实例代码
  • jquery达成模拟百分比进度条渐变效果代码
  • jQuery达成渐变弹出层和弹出菜单的不二秘技
  • jquery实现鼠标经过呈现下划线的渐变下拉菜单效果代码
  • jQuery落成字体颜色渐变效果的主意

效果很科学啊?会不会误以为这几个字体是图片?那可不是图片,而是用JS达成的 在线演示 ...

本文由澳门新萄京官方网站发布于澳门新萄京赌场网址,转载请注明出处:SO销路好问答,音信头条淡入淡出效果

关键词: