热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

IE8及其以下浏览器边框圆角兼容问题

css部分html部分behavior:url(iecss3.htc);iecss3.htc复制如下代码取名iecss3.htc原文:https:www.cnblogs.comBe

css部分

yuan {
border: 2px solid #C0C0C0;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
position: relative;
padding: 5px;
/* background: #FFF; */
z-index: 2;
overflow: hidden;
width: 100px;
height: 100px;
behavior: url(ie-css3.htc);
}

html部分



DIVCSS5圆角实例
CSS3版本圆角实例,
支持低版本IE6-IE9浏览器







var match = style.match(/^(\d+)px (\d+)px (\d+)px/);
if (!match) { return(false); }
var shadow = document.createElement('v:roundrect');
shadow.userAttrs = {
'x': parseInt(RegExp.$1 || 0),
'y': parseInt(RegExp.$2 || 0),
'radius': parseInt(RegExp.$3 || 0) / 2
};
shadow.position_offset = {
'y': (0 - vml_parent.pos_ieCSS3.y - shadow.userAttrs.radius + shadow.userAttrs.y),
'x': (0 - vml_parent.pos_ieCSS3.x - shadow.userAttrs.radius + shadow.userAttrs.x)
};
shadow.size_offset = {
'width': 0,
'height': 0
};
shadow.arcsize = element.arcSize +'px';
shadow.style.display = 'block';
shadow.style.position = 'absolute';
shadow.style.top = (element.pos_ieCSS3.y + shadow.position_offset.y) +'px';
shadow.style.left = (element.pos_ieCSS3.x + shadow.position_offset.x) +'px';
shadow.style.width = element.offsetWidth +'px';
shadow.style.height = element.offsetHeight +'px';
shadow.style.antialias = true;
shadow.className = 'vml_box_shadow';
shadow.style.zIndex = element.zIndex - 1;
shadow.style.filter = 'progid:DXImageTransform.Microsoft.Blur(pixelRadius='+ shadow.userAttrs.radius +',makeShadow=true,shadowOpacity='+ element.opacity +')';
element.parentNode.appendChild(shadow);
//element.parentNode.insertBefore(shadow, element.element);
// For window resizing
element.vml.push(shadow);
return(true);
}
function createBorderRect(element, vml_parent) {
if (isNaN(element.borderRadius)) { return(false); }
element.style.background = 'transparent';
element.style.borderColor = 'transparent';
var rect = document.createElement('v:roundrect');
rect.position_offset = {
'y': (0.5 * element.strokeWeight) - vml_parent.pos_ieCSS3.y,
'x': (0.5 * element.strokeWeight) - vml_parent.pos_ieCSS3.x
};
rect.size_offset = {
'width': 0 - element.strokeWeight,
'height': 0 - element.strokeWeight
};
rect.arcsize = element.arcSize +'px';
//rect.arcsize = element.arcSize / (element.offsetWidth + rect.size_offset.width);
rect.strokeColor = element.strokeColor;
rect.strokeWeight = element.strokeWeight +'px';
rect.stroked = element.stroked;
rect.className = 'vml_border_radius';
rect.style.display = 'block';
rect.style.position = 'absolute';
rect.style.top = (element.pos_ieCSS3.y + rect.position_offset.y) +'px';
rect.style.left = (element.pos_ieCSS3.x + rect.position_offset.x) +'px';
rect.style.width = (element.offsetWidth + rect.size_offset.width) +'px';
rect.style.height = (element.offsetHeight + rect.size_offset.height) +'px';
rect.style.antialias = true;
rect.style.zIndex = element.zIndex - 1;
if (border_opacity && (element.opacity <1)) {
rect.style.filter = &#39;progid:DXImageTransform.Microsoft.Alpha(Opacity=&#39;+ parseFloat(element.opacity * 100) +&#39;)&#39;;
}
var fill = document.createElement(&#39;v:fill&#39;);
fill.color = element.fillColor;
fill.src = element.fillSrc;
fill.className = &#39;vml_border_radius_fill&#39;;
fill.type = &#39;tile&#39;;
fill.opacity = element.opacity;
// Hack: IE6 doesn&#39;t support transparent borders, use padding to offset original element
isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
if (isIE6 && (element.strokeWeight > 0)) {
element.style.borderStyle = &#39;none&#39;;
element.style.paddingTop = parseInt(element.currentStyle.paddingTop || 0) + element.strokeWeight;
element.style.paddingBottom = parseInt(element.currentStyle.paddingBottom || 0) + element.strokeWeight;
}
rect.appendChild(fill);
element.parentNode.appendChild(rect);
//element.parentNode.insertBefore(rect, element.element);
// For window resizing
element.vml.push(rect);
return(true);
}
function createTextShadow(element, vml_parent) {
if (!element.textShadow) { return(false); }
var match = element.textShadow.match(/^(\d+)px (\d+)px (\d+)px (#?\w+)/);
if (!match) { return(false); }
//var shadow = document.createElement(&#39;span&#39;);
var shadow = element.cloneNode(true);
var radius = parseInt(RegExp.$3 || 0);
shadow.userAttrs = {
&#39;x&#39;: parseInt(RegExp.$1 || 0) - (radius),
&#39;y&#39;: parseInt(RegExp.$2 || 0) - (radius),
&#39;radius&#39;: radius / 2,
&#39;color&#39;: (RegExp.$4 || &#39;#000&#39;)
};
shadow.position_offset = {
&#39;y&#39;: (0 - vml_parent.pos_ieCSS3.y + shadow.userAttrs.y),
&#39;x&#39;: (0 - vml_parent.pos_ieCSS3.x + shadow.userAttrs.x)
};
shadow.size_offset = {
&#39;width&#39;: 0,
&#39;height&#39;: 0
};
shadow.style.color = shadow.userAttrs.color;
shadow.style.position = &#39;absolute&#39;;
shadow.style.top = (element.pos_ieCSS3.y + shadow.position_offset.y) +&#39;px&#39;;
shadow.style.left = (element.pos_ieCSS3.x + shadow.position_offset.x) +&#39;px&#39;;
shadow.style.antialias = true;
shadow.style.behavior = null;
shadow.className = &#39;ieCSS3_text_shadow&#39;;
shadow.innerHTML = element.innerHTML;
// For some reason it only looks right with opacity at 75%
shadow.style.filter = &#39;progid:DXImageTransform.Microsoft.Alpha(Opacity=75)progid:DXImageTransform.Microsoft.Blur(pixelRadius=&#39;+ shadow.userAttrs.radius +&#39;,makeShadow=false,shadowOpacity=100)&#39;;
var clOne= element.cloneNode(true);
clone.position_offset = {
&#39;y&#39;: (0 - vml_parent.pos_ieCSS3.y),
&#39;x&#39;: (0 - vml_parent.pos_ieCSS3.x)
};
clone.size_offset = {
&#39;width&#39;: 0,
&#39;height&#39;: 0
};
clone.style.behavior = null;
clone.style.position = &#39;absolute&#39;;
clone.style.top = (element.pos_ieCSS3.y + clone.position_offset.y) +&#39;px&#39;;
clone.style.left = (element.pos_ieCSS3.x + clone.position_offset.x) +&#39;px&#39;;
clone.className = &#39;ieCSS3_text_shadow&#39;;
element.parentNode.appendChild(shadow);
element.parentNode.appendChild(clone);
element.style.visibility = &#39;hidden&#39;;
// For window resizing
element.vml.push(clone);
element.vml.push(shadow);
return(true);
}
function ondocumentready(classID) {
if (!supportsVml()) { return(false); }
if (this.className.match(classID)) { return(false); }
this.className = this.className.concat(&#39; &#39;, classID);
// Add a namespace for VML (IE8 requires it)
if (!document.namespaces.v) { document.namespaces.add("v", "urn:schemas-microsoft-com:vml"); }
// Check to see if we&#39;ve run once before on this page
if (typeof(window.ieCSS3) == &#39;undefined&#39;) {
// Create global ieCSS3 object
window.ieCSS3 = {
&#39;vmlified_elements&#39;: new Array(),
&#39;update_timer&#39;: setInterval(updatePositionAndSize, timer_length)
};
if (typeof(window.onresize) == &#39;function&#39;) { window.ieCSS3.previous_Onresize= window.onresize; }
// Attach window resize event
window.Onresize= updatePositionAndSize;
}
// These attrs are for the script and have no meaning to the browser:
this.borderRadius = parseInt(this.currentStyle[&#39;iecss3-border-radius&#39;] ||
this.currentStyle[&#39;-moz-border-radius&#39;] ||
this.currentStyle[&#39;-webkit-border-radius&#39;] ||
this.currentStyle[&#39;border-radius&#39;] ||
this.currentStyle[&#39;-khtml-border-radius&#39;]);
this.arcSize = Math.min(this.borderRadius / Math.min(this.offsetWidth, this.offsetHeight), 1);
this.fillColor = this.currentStyle.backgroundColor;
this.fillSrc = this.currentStyle.backgroundImage.replace(/^url\("(.+)"\)$/, &#39;$1&#39;);
//add by emptyhua@gmail.com
if (this.fillSrc == &#39;none&#39;)
this.fillSrc = &#39;Javascript:void(0);&#39;;
this.strokeColor = this.currentStyle.borderColor;
this.strokeWeight = parseInt(this.currentStyle.borderWidth);
this.stroked = &#39;true&#39;;
if (isNaN(this.strokeWeight) || (this.strokeWeight == 0)) {
this.strokeWeight = 0;
this.strokeColor = fillColor;
this.stroked = &#39;false&#39;;
}
this.opacity = parseFloat(this.currentStyle.opacity || 1);
this.textShadow = this.currentStyle[&#39;text-shadow&#39;];
this.element.vml = new Array();
this.zIndex = parseInt(this.currentStyle.zIndex);
if (isNaN(this.zIndex)) { this.zIndex = 0; }
// Find which element provides position:relative for the target element (default to BODY)
vml_parent = this;
var limit = 100, i = 0;
do {
vml_parent = vml_parent.parentElement;
i++;
if (i >= limit) { return(false); }
} while ((typeof(vml_parent) != &#39;undefined&#39;) && (vml_parent.currentStyle.position != &#39;relative&#39;) && (vml_parent.tagName != &#39;BODY&#39;));
vml_parent.pos_ieCSS3 = findPos(vml_parent);
this.pos_ieCSS3 = findPos(this);
var rv1 = createBoxShadow(this, vml_parent);
var rv2 = createBorderRect(this, vml_parent);
var rv3 = createTextShadow(this, vml_parent);
if (rv1 || rv2 || rv3) { window.ieCSS3.vmlified_elements.push(this.element); }
if (typeof(vml_parent.document.ieCSS3_stylesheet) == &#39;undefined&#39;) {
vml_parent.document.ieCSS3_stylesheet = vml_parent.document.createStyleSheet();
vml_parent.document.ieCSS3_stylesheet.addRule("v\\:roundrect", "behavior: url(#default#VML)");
vml_parent.document.ieCSS3_stylesheet.addRule("v\\:fill", "behavior: url(#default#VML)");
// Compatibility with IE7.js
vml_parent.document.ieCSS3_stylesheet.ie7 = true;
}
}
function updatePositionAndSize() {
if (typeof(window.ieCSS3.vmlified_elements) != &#39;object&#39;) { return(false); }
for (var i in window.ieCSS3.vmlified_elements) {
var el = window.ieCSS3.vmlified_elements[i];
if (typeof(el.vml) != &#39;object&#39;) { continue; }
for (var z in el.vml) {
//var parent_pos = findPos(el.vml[z].parentNode);
var new_pos = findPos(el);
new_pos.x = (new_pos.x + el.vml[z].position_offset.x) + &#39;px&#39;;
new_pos.y = (new_pos.y + el.vml[z].position_offset.y) + &#39;px&#39;;
if (el.vml[z].style.left != new_pos.x) { el.vml[z].style.left = new_pos.x; }
if (el.vml[z].style.top != new_pos.y) { el.vml[z].style.top = new_pos.y; }
var new_size = {
&#39;width&#39;: parseInt(el.offsetWidth + el.vml[z].size_offset.width),
&#39;height&#39;: parseInt(el.offsetHeight + el.vml[z].size_offset.height)
}
if (el.vml[z].offsetWidth != new_size.width) { el.vml[z].style.width = new_size.width +&#39;px&#39;; }
if (el.vml[z].offsetHeight != new_size.height) { el.vml[z].style.height = new_size.height +&#39;px&#39;; }
}
}
if (event && (event.type == &#39;resize&#39;) && typeof(window.ieCSS3.previous_onresize) == &#39;function&#39;) { window.ieCSS3.previous_onresize(); }
}
// added by emptyhua@gmail.com 2010 7-3
window.update_css3_fix_position = updatePositionAndSize;
window.update_css3_fix = function(el)
{
if (!el.vml) return;
el.arcSize = Math.min(el.borderRadius / Math.min(el.offsetWidth, el.offsetHeight), 1);
// Find which element provides position:relative for the target element (default to BODY)
var vml_parent = el;
var limit = 100, i = 0;
do {
vml_parent = vml_parent.parentElement;
i++;
if (i >= limit) { return(false); }
} while ((typeof(vml_parent) != &#39;undefined&#39;) && (vml_parent.currentStyle.position != &#39;relative&#39;) && (vml_parent.tagName != &#39;BODY&#39;));
vml_parent.pos_ieCSS3 = findPos(vml_parent);
el.pos_ieCSS3 = findPos(el);
for (i in el.vml)
{
element.parentNode.removeChild(el.vml[i]);
}
el.vml = [];
var rv1 = createBoxShadow(el, vml_parent);
var rv2 = createBorderRect(el, vml_parent);
};

技术分享图片

原文:https://www.cnblogs.com/BelieveWang/p/8027256.html


推荐阅读
  • 本文介绍了lua语言中闭包的特性及其在模式匹配、日期处理、编译和模块化等方面的应用。lua中的闭包是严格遵循词法定界的第一类值,函数可以作为变量自由传递,也可以作为参数传递给其他函数。这些特性使得lua语言具有极大的灵活性,为程序开发带来了便利。 ... [详细]
  • 本文介绍了使用Java实现大数乘法的分治算法,包括输入数据的处理、普通大数乘法的结果和Karatsuba大数乘法的结果。通过改变long类型可以适应不同范围的大数乘法计算。 ... [详细]
  • HDU 2372 El Dorado(DP)的最长上升子序列长度求解方法
    本文介绍了解决HDU 2372 El Dorado问题的一种动态规划方法,通过循环k的方式求解最长上升子序列的长度。具体实现过程包括初始化dp数组、读取数列、计算最长上升子序列长度等步骤。 ... [详细]
  • 本文讨论了如何优化解决hdu 1003 java题目的动态规划方法,通过分析加法规则和最大和的性质,提出了一种优化的思路。具体方法是,当从1加到n为负时,即sum(1,n)sum(n,s),可以继续加法计算。同时,还考虑了两种特殊情况:都是负数的情况和有0的情况。最后,通过使用Scanner类来获取输入数据。 ... [详细]
  • 本文介绍了C#中数据集DataSet对象的使用及相关方法详解,包括DataSet对象的概述、与数据关系对象的互联、Rows集合和Columns集合的组成,以及DataSet对象常用的方法之一——Merge方法的使用。通过本文的阅读,读者可以了解到DataSet对象在C#中的重要性和使用方法。 ... [详细]
  • 本文介绍了OC学习笔记中的@property和@synthesize,包括属性的定义和合成的使用方法。通过示例代码详细讲解了@property和@synthesize的作用和用法。 ... [详细]
  • 本文详细介绍了Linux中进程控制块PCBtask_struct结构体的结构和作用,包括进程状态、进程号、待处理信号、进程地址空间、调度标志、锁深度、基本时间片、调度策略以及内存管理信息等方面的内容。阅读本文可以更加深入地了解Linux进程管理的原理和机制。 ... [详细]
  • 1,关于死锁的理解死锁,我们可以简单的理解为是两个线程同时使用同一资源,两个线程又得不到相应的资源而造成永无相互等待的情况。 2,模拟死锁背景介绍:我们创建一个朋友 ... [详细]
  • 《数据结构》学习笔记3——串匹配算法性能评估
    本文主要讨论串匹配算法的性能评估,包括模式匹配、字符种类数量、算法复杂度等内容。通过借助C++中的头文件和库,可以实现对串的匹配操作。其中蛮力算法的复杂度为O(m*n),通过随机取出长度为m的子串作为模式P,在文本T中进行匹配,统计平均复杂度。对于成功和失败的匹配分别进行测试,分析其平均复杂度。详情请参考相关学习资源。 ... [详细]
  • 动态规划算法的基本步骤及最长递增子序列问题详解
    本文详细介绍了动态规划算法的基本步骤,包括划分阶段、选择状态、决策和状态转移方程,并以最长递增子序列问题为例进行了详细解析。动态规划算法的有效性依赖于问题本身所具有的最优子结构性质和子问题重叠性质。通过将子问题的解保存在一个表中,在以后尽可能多地利用这些子问题的解,从而提高算法的效率。 ... [详细]
  • 高质量SQL书写的30条建议
    本文提供了30条关于优化SQL的建议,包括避免使用select *,使用具体字段,以及使用limit 1等。这些建议是基于实际开发经验总结出来的,旨在帮助读者优化SQL查询。 ... [详细]
  • 本文介绍了指针的概念以及在函数调用时使用指针作为参数的情况。指针存放的是变量的地址,通过指针可以修改指针所指的变量的值。然而,如果想要修改指针的指向,就需要使用指针的引用。文章还通过一个简单的示例代码解释了指针的引用的使用方法,并思考了在修改指针的指向后,取指针的输出结果。 ... [详细]
  • 猜字母游戏
    猜字母游戏猜字母游戏——设计数据结构猜字母游戏——设计程序结构猜字母游戏——实现字母生成方法猜字母游戏——实现字母检测方法猜字母游戏——实现主方法1猜字母游戏——设计数据结构1.1 ... [详细]
  • Mac OS 升级到11.2.2 Eclipse打不开了,报错Failed to create the Java Virtual Machine
    本文介绍了在Mac OS升级到11.2.2版本后,使用Eclipse打开时出现报错Failed to create the Java Virtual Machine的问题,并提供了解决方法。 ... [详细]
  • 在说Hibernate映射前,我们先来了解下对象关系映射ORM。ORM的实现思想就是将关系数据库中表的数据映射成对象,以对象的形式展现。这样开发人员就可以把对数据库的操作转化为对 ... [详细]
author-avatar
没搜摸索摸索_685
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有