css3--border属性
2015-09-16 15:34
585 查看
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>01</title> </head> <style> /*1、基本*/ .one{ height: 200px; width: 200px; border-style: solid ; border-width:2px ; border-color: red; border-radius: 0; box-shadow: 5px 5px 20px #000000; border-image: url(../img/border.png); border-image-slice: 26; border-image-width: 26; /* border-image-outset: 20; */ border-image-repeat: stretch round; } /*2、兼容ie8*/ .two{ height: 200px; width: 200px; border-style: solid ; border-width:2px ; border-color: red; border-radius: 50%; box-shadow: 5px 5px 20px #000000; /*ie8*/ -ms-filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=2px, OffY=2px, Color='#000000')"; /* IE8 */ } /*3、js控制*/ .three{ width: 200px; height: 200px; border: 1px solid red; border-radius: 0px; } </style> <script> window.onload=function(){ try{ /* //这个方法实现起来,速度比较慢。 var div=document.getElementsByTagName('div')[2];//居然用getElementsByClassName()会失败,真奇葩!!! console.log(div.offsetWidth); var radius=0; var t; div.onmouseover=function () { clearInterval(t); console.log("鼠标在其上之时,触发事件!!!"); t=setInterval(function(){ if(parseInt(div.style.borderRadius)>=div.offsetWidth/2){ clearInterval(t); } else{ radius++; //console.log(radius); div.style.borderRadius=radius+'px'; } },60); }; div.onmouseout=function () { clearInterval(t); console.log("鼠标在离开其之时,触发事件!!!"); t=setInterval(function(){ if(parseInt(div.style.borderRadius)<=0){ clearInterval(t); } else{ radius--; //console.log('离开'+radius); div.style.borderRadius=radius+'px'; } },60); }; }catch(e){ console.log(e); } */ //优化代码 var div=document.getElementsByTagName('div')[2];/*居然用getElementsByClassName()会失败,真奇葩!!!*/ var t; div.onmouseover=function () { clearInterval(t); console.log("鼠标在其上之时,触发事件!!!"); console.log(parseInt(div.style.borderRadius)); /* *注:1、div.style.borderRadius如果是获取使用css样式的话,如0px,获取到的数据为NaN。 * 2、<div class="three" style="border-radius:0;"></div>,可正确获取。 * */ t=setInterval(function(){ if(parseInt(div.style.borderRadius)>=div.offsetWidth/2){ clearInterval(t); } else{ var radius=(div.offsetWidth/2-parseInt(div.style.borderRadius))*0.2; //console.log(div.offsetWidth/2-parseInt(div.style.borderRadius)); div.style.borderRadius=parseInt(div.style.borderRadius)+radius+"px"; } },60); }; div.onmouseout=function () { clearInterval(t); console.log("鼠标在离开其之时,触发事件!!!"); console.log(div.style.borderRadius); t=setInterval(function(){ if(parseInt(div.style.borderRadius)<=0){ clearInterval(t); } else{ var radius=(0-parseInt(div.style.borderRadius))*0.2; div.style.borderRadius=parseInt(div.style.borderRadius)+radius+"px"; } },60); }; }catch(e){ console.log(e); } } </script> <body> <div class="one"></div> <div class="two"></div> <div class="three" style="border-radius:0;"></div> </body> </html>
相关文章推荐
- css解决文字垂直居中
- CSS display:table属性用法解析
- CSS selector选择符 进行CSS网页布局的基础
- My97DatePicker 与 某个CSS冲突 ,导致无法显示
- SpannableString 给TextView添加不同的显示样式
- SpannableString 给TextView添加不同的显示样式
- SpannableString 给TextView添加不同的显示样式
- 使用 CSS3 实现超炫的 Loading(加载)动画效果
- CSS中!improtant的使用
- css选择符有哪些?哪些属性可以继承?优先级算法如何计算?内联和important哪个优先
- CSS position属性的四个值:static,absolute,fixed,relative
- css
- CSS3 transform的skew属性值图文详解
- 包罗万象的JS功能,配上刚刚发布的CSS简直是完美,没有前端的IT好好看看
- 直接调用的CSS超级棒的哦,用过才知道,整理好久才整理出来的,下一篇会发使用说明
- CSS中font-size属性值四大种类
- CSS代码结构中id及class类命名探究
- 【CSS】单行图片与文字垂直居中
- 用CSS变形创建圆形导航
- IE中中CSS伪类:hover的使用及其BUG