IE7,8纯css实现圆角效果

众所周知,IE7,8不支持border-radius效果。但我们同样有办法用css实现这个效果,方法就是用border来模拟。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        div{
            position: relative;
            width: 150px;
            height: 150px;
            line-height: 150px;
            overflow: hidden;
        }
        .radius{
            position: absolute;
            width: 100%;
            height: 100%;
            margin: 0 0 1px 1px;
            /*现代浏览器就使用border-radius*/
            border-radius: 50%;
            /*IE7,8就使用border来模拟*/
            border: 149px dotted;
            border-width: 0vw;
            margin: 0vw;
            color: #cd0000;
            background-color: currentColor;
        }
        .text{
            position: relative;
            text-align: center;
            color: #fff;
            font-size: 24px;
            margin: 0;
        }
    </style>
</head>
<body>
    <div>
        <p class="radius"></p>
        <p class="text">kobe</p>
    </div>
</body>
</html>

vw单位可能大家用的比较少,因为这个单位是IE9+才支持,所以现代浏览器直接把边框设为0vw,就表示无边框,直接使用border-radius,而IE7,8则使用border来模拟。

具体可查看这里

时间: 2024-08-08 01:59:10

IE7,8纯css实现圆角效果的相关文章

纯CSS实现圆角效果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

利用target的特性,可以实现纯css的tab效果切换

基础知识: :target起作用的是href连接到的位置 如 <a href="#tab1">tab1</a> <div id="tab1" class="tab">This is a tab1</div> :target{ color:red; } 但点击a标签的时候,连接到id是tab1的div,对这个div起作用color:red; 如: <a href="#tab"

HTML5 CSS3专题 纯CSS打造相册效果

转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/30993277 今天偶然发现电脑里面还有这样的一个例子,感觉效果还不错,不记得啥时候下载的了,也好久没上w3cfuns了,怀念学习前台的日子,给大家分享下. 效果图: 效果是不是还是很不错的,最主要的是没有使用一行js,这才是亮点. 先看html文件: <body> <div id="gallery"> <h1>纯CSS3相册效果&l

纯CSS实现圆角边框

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

纯css实现计数器效果

先上效果图: 点击选项框,下面的数字动态显示总个数,该效果由纯css实现.怎么实现的呢?主要就是靠css中的计数器counter. css的counter-reset属性可以设置一个计数器,并通过counter-increment属性实现递增效果.具体可以看代码: 1 html{ 2 counter-reset:section; 3 } 4 input:checked{ 5 counter-increment:section; 6 } 7 .counter:after{ 8 以下菜系,你喜欢哪些

纯css实现打字效果

概述 很早以前就在别人的博客上面看到打字动画了,觉得非常炫酷,以为是用js做的,找了半天也没找到js在哪里.今天看<css揭秘>,碰巧看到书上打字动画的实现了,而且是纯css实现的!我参考这本书把代码记录下来,供以后开发时参考,相信对其他人也有用. 代码 书上的css代码是这样的: @keyframes typing { from { width: 0 } /* 从左到右的动画 */ } @keyframes caret { 50% { border-color: transparent; }

纯css做幻灯片效果

css3里面有一个@keyframes动画功能. w3c上面的例子: 可以使用它来做一个幻灯片效果. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>纯CSS做幻灯片</title> </head> <style> @keyframes slide { 0% { backgroun

css实现圆角效果

源码: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <style> .b1, .b2, .b3, .b4, .b5, .b6, .b7, .b8 { height:1px; font-size:1px; overflow:hidden; display:block; } .b1, .b8 { m

使用纯css实现波浪效果

有时候我们需要实现水晃动的效果,其实我们可以通过css旋转动画和圆角来实现. 首先来2个div,外层div相对定位,内层div绝对定位,内层div大致位于外层div上半部分.外层div设置一个颜色较深的背景色(水的颜色);内层div颜色设置为白色,加上圆角,圆角建议30%-45%之间,然后加上无限循环的旋转动画,通过内层div的旋转来实现波浪效果. 参考代码如下: <style> #container{ width:400px; height:200px; position: relative