按钮特效(CSS3)_html/css_WEB-ITnose
先预览效果
其中用到了CSS3的Transition属性:设置动画时间、效果;Transform属性:设置元素旋转、位移;box-sizing属性:以特定的方式定义某个区域的特定元素;
制作小三角方法:
1 width:0; height:0; overflow:hidden; 2 border:7px solid transparent; 3 border-top-color:#2dcb70; /*宽高都为零,先设置边框为透明,再在需要的地方给边框单独设置颜色即可*/
HTML代码
1 <div class="box"> 2 <div class="link link-miss"> 3 <span class="icon"></span> 4 <a href="#" class="button" data="My mission is clear"> 5 <span class="line line-top"></span> 6 <span class="line line-right"></span> 7 <span class="line line-bottom"></span> 8 <span class="line line-left"></span> 9 MISSION10 </a>11 </div>12 <div class="link link-play">13 <span class="icon"></span>14 <a href="#" class="button" data="This is my playGroup">15 <span class="line line-top"></span>16 <span class="line line-right"></span>17 <span class="line line-bottom"></span>18 <span class="line line-left"></span>19 PLAY20 </a>21 </div>22 <div class="link link-touch">23 <span class="icon"></span>24 <a href="#" class="button" data="This is my Touch">25 <span class="line line-top"></span>26 <span class="line line-right"></span>27 <span class="line line-bottom"></span>28 <span class="line line-left"></span>29 TOUCH30 </a>31 </div>32 <div class="tip">33 <em></em><span></span>34 </div>35 </div>
CSS代码
1 *{margin:0; 2 padding:0;} 3 4 body{background:#333;} 5 .box { 6 width:800px; height:280px; margin: 50px auto; 7 } 8 .box .link { 9 width:205px; height:280px; float: left; margin:0 20px; 10 } 11 .link .icon { 12 display:inline-block; width:100%; height:190px; cursor:pointer; 13 transition:ease-out 0.2s; 14 } 15 .link-miss .icon { 16 background:url(../images/mission.png) no-repeat center; 17 } 18 .link-play .icon { 19 background:url(../images/play.png) no-repeat center; 20 } 21 .link-touch .icon { 22 background:url(../images/touch.png) no-repeat center; 23 } 24 .link .icon:hover { 25 transform:rotate(360deg) scale(1.2); 26 } 27 .button { 28 display:block; width:180px; height:50px; line-height: 50px; text-decoration: none; color:#2dcb70; 29 font-family: Arial; font-weight: bolder; border:2px solid rgba(255,255,255,0.6); 30 padding-left: 20px; margin:0 auto; background: url(../images/allow.png) no-repeat 130px center; 31 box-sizing:border-box; 32 transition:0.4s ease; 33 position: relative; 34 } 35 .button:hover { 36 border:2px solid rgba(255,255,255,1); 37 background-position: 140px center; 38 } 39 /* 40 CSS3--Transition 41 语法:transition:property duration timing-function delay; 42 描述: 43 transition-property:规定设置过渡效果的CSS属性的名称; 44 transition-duration:规定完成过渡效果需要多少秒或毫秒; 45 transition-timing-function:规定速度效果的速度曲线; 46 transition-delay:定义过渡效果何时开始; 47 CSS3--Transform 48 transform属性向元素应用2D或3D转换;该属性允许我们对元素进行旋转/缩放/移动或倾斜; 49 CSS3--box-sizing 50 box-sizing属性允许以特定的方式定义匹配某个区域的特定元素; 51 语法:box-sizing:content-box | border-box | inherit; 52 描述: 53 content-box:(默认值)宽度和高度分别应用到元素的内容框,在宽度和高度的基础上绘制元素的内边距和边框; 54 border-box:为元素指定的任何内边距和边框都将在已设定的宽度和高度内进行绘制; 55 通过已设定的宽度和高度分别减去边框和内边距才能得到内容的实际宽度和高度; 56 */ 57 .button .line { 58 position: absolute; background: none; transition:0.4s; 59 } 60 .button:hover .line { 61 background: #f00; 62 } 63 64 .button .line-top { 65 width:0px; height:2px; top:-2px; left:-110%; 66 } 67 .button:hover .line-top { 68 width:180px; left:-2px; 69 } 70 71 .button .line-right { 72 width:2px; height:0px; right:-2px; top:-110%; 73 } 74 .button:hover .line-right { 75 height:50px; top:-2px; 76 } 77 78 .button .line-bottom { 79 width:0px; height:2px; bottom:-2px; right:-110%; 80 } 81 .button:hover .line-bottom { 82 width:180px; right:-2px; 83 } 84 85 .button .line-left { 86 width:2px; height:0px; left:-2px; bottom:-110%; 87 } 88 .button:hover .line-left { 89 height:50px; bottom:-2px; 90 } 91 .tip { 92 position: absolute; padding: 0 14px; height:35px; line-height: 35px; background: #2dcb70; 93 color:#fff; font-size: 18px; margin: 0 auto; border-radius: 3px; top:160px; opacity:0; 94 } 95 .tip em { 96 font-style: normal; font-size: 18px; color:#fff; 97 } 98 .tip span { 99 display: block; width:0; height:0; overflow: hidden; position: absolute; top:35px; left:50%;100 border:7px solid transparent; border-top-color:#2dcb70; margin-left: -3px;101 }
JQuery代码
1 $(function(){ 2 $('.link .button').hover(function(){ 3 var title = $(this).attr('data'); 4 $('.tip em').text(title); 5 var pos = $(this).offset().left; 6 var dis = parseInt($('.tip').outerWidth()-$(this).outerWidth())/2; 7 var l = pos - dis; 8 $('.tip').css({'left':l+'px'}).animate({'top':180,'opacity':1},300); 9 },function(){10 if(!$('.tip').is(':animated')){11 $('.tip').animate({'top':160,'opacity':0},50);12 }13 })14 });
学自慕课网http://www.imooc.com/learn/5

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제









이 기사는 HTML & LT; Datalist & GT에 대해 논의합니다. 자동 완성 제안을 제공하고, 사용자 경험을 향상시키고, 오류를 줄임으로써 양식을 향상시키는 요소. 문자 수 : 159

이 기사는 HTML & lt; Progress & Gt에 대해 설명합니다. 요소, 그 목적, 스타일 및 & lt; meter & gt의 차이; 요소. 주요 초점은 & lt; progress & gt; 작업 완료 및 & lt; meter & gt; Stati의 경우

이 기사는 HTML & lt; meter & gt에 대해 설명합니다. 범위 내에 스칼라 또는 분수 값을 표시하는 데 사용되는 요소 및 웹 개발의 일반적인 응용 프로그램. & lt; meter & gt; & lt; Progress & Gt; 그리고 Ex

이 기사는 & lt; iframe & gt; 외부 컨텐츠를 웹 페이지, 공통 용도, 보안 위험 및 객체 태그 및 API와 같은 대안을 포함시키는 태그의 목적.

이 기사는 모바일 장치의 반응 형 웹 디자인에 필수적인 Viewport Meta Tag에 대해 설명합니다. 적절한 사용이 최적의 컨텐츠 스케일링 및 사용자 상호 작용을 보장하는 방법을 설명하는 반면, 오용은 설계 및 접근성 문제로 이어질 수 있습니다.

이 기사에서는 브라우저에서 직접 사용자 입력을 검증하기 위해 필요한, Pattern, Min, Max 및 Length 한계와 같은 HTML5 양식 검증 속성을 사용하는 것에 대해 설명합니다.

기사는 HTML5 크로스 브라우저 호환성을 보장하기위한 모범 사례에 대해 논의하고 기능 감지, 점진적 향상 및 테스트 방법에 중점을 둡니다.

이 기사는 html5 & lt; time & gt; 시맨틱 날짜/시간 표현 요소. 인간이 읽을 수있는 텍스트와 함께 기계 가독성 (ISO 8601 형식)에 대한 DateTime 속성의 중요성을 강조하여 Accessibilit를 향상시킵니다.
