標籤:style http color os strong io width for
/*------------------ITEYE 祈禱幸福(http://qidaoxingfu.iteye.com)原創 轉載請註明-----------------*/
效果。Ps、背景線條是背景圖勒,和本文效果無關。。。
html代碼如下:
Html代碼
- <div class="content">
- <h3 title="專業技能">專業技能</h3>
- <div class="next"><!--其他內容--></div>
- </div>
有兩種實現方式:
1.box-reflect
(屬性詳情見http://css.doyoe.com/ 屬性→邊框→box-reflect)
Css代碼
- .content h3{
- opacity:0.7;
- font:40px/50px ‘Microsoft yahei‘;
- -webkit-box-reflect: below 5px -webkit-gradient(linear, center top, center bottom, from(transparent),color-stop(0.2, transparent), to(white));
- }
但是box-reflect屬性只有chrome/Safari支援(支援詳情見 http://caniuse.com/#search=box-reflect)
FF和Opera不能相容,所以有了以下替代方案。
2.transform屬性的scaleY方式:
受到神飛的博文和MDN的一個Demo原始碼的啟發
MDN Demo https://developer.mozilla.org/zh-CN/demos/detail/css3-reflection-effect/launch
神飛:一些上流的CSS3圖片樣式 http://www.qianduan.net/css3-image-styles.html
Css代碼
- .content h3{
- position:relative;
- float:left;
- opacity:0.7;
- font:40px/50px ‘Microsoft yahei‘;
- }
-
- .content h3:before{
- content:attr(title);
- position:absolute;
- z-index:1;
- top:100%;
- left:0;
- height:100%;
- width:100%;
- -webkit-transform:scaleY(-1);
- }
-
- .content h3:after{
- content:‘‘;
- position:absolute;
- z-index:2;
- top:100%;
- left:0;
- height:100%;
- width:100%;
- background:-webkit-gradient(linear, center top, center bottom, from(rgba(255,255,255,0)), to(rgba(255,255,255,1)));/*其他幾個被省略了-_-!*/
- }
-
- .content .next{
- clear:both;
- padding:60px;
- }
注:前面h3元素浮動是為了讓文字塊的寬度動態地剛好等同文字寬度,否則塊過長,導致after的遮罩延長,影響右邊沒有文字的部分