转盘不转动的问题

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

jQuery Rotate - IE7 & IE8 Issues



up vote

11

down vote

favorite

3

I am using Jquery Rotate to rotate an image around a meter, and it works great but in IE7 and IE8 it gets pushed up about 200 pixels and has a black stroke/border around the image.


I am using jQueryRotate3.js which has it working, but the position is off, and not sure where the black border is coming from?


JS:


            var start = 0;

        // Sets the Value of the City for now   

            var angle = 1 + Math.floor(Math.random() * 180);


            $("img.pointer").rotate({

                 angle: start,

                 animateTo: angle,

                 easing: $.easing.easeInOutSine

            })

HTML:


<div class="city-details">

   <div class="details">

     <img class="pointer" src="http://demo.omnigon.com/christian_bovine/shamelesscity/images/pointer.png" alt="" />

    </div>

</div>

You can see the code here: http://jsfiddle.net/xtian/6gcS8/1/


I would really like to get this working in IE7 and IE8.


jquery rotation image-rotation

shareimprove this question

asked Dec 5 '12 at 20:31


Xtian

79342865

 

That looks like the plugin jQueryRotate3.js is doin something funky because if you comment out your JS the position is fine –  Ronnie Dec 7 '12 at 22:59

 

IE9 < has problems with filter and PNGs (it's not only IE6), the black border happens because of the alpha channel. You may use a 8bit PNG or a gif, it would work. –  pocesar Dec 7 '12 at 23:14

add a comment

3 Answers

activeoldestvotes

up vote

5

down vote

accepted

+100

jsFiddle DEMO


I looked into the jQuery Rotate v3.1 script your using and it's sparse with just the minimal it needs to get the job done for IE, which is nice considering.


Just include two CSS rules for top and left, based on your margin-top and margin-left values to have it working in IE series of non CSS3 browsers.


Example:


img.pointer{

    display: block;

    width: 192px;

    height: 11px;

    top: 211px;

    left: 48px;    

    margin: 211px 0 0 48px;

}

Note there is no need to set CSS position since this script sets it to absolute which over-rides anything you provide.


A method to fix the image black border issue in IE browsers is to set the background-color property to the value that matches the background... expect in your case you have 3 colors of blue along with white in the middle section... so that's not a good idea.


Instead, use the most common solution which is a PNG8 Filetype Image with Transparency, as discussed in this SO Answer.


shareimprove this answer

edited Dec 9 '12 at 12:10


answered Dec 9 '12 at 11:29


arttronics

8,93521545

 

Having used a PNG8 with alpha transparency, this approach, which normally solves transparency issues with IE, does not work in ie7/8. There are still black borders after rotation. –  robert.egginton Jun 25 '13 at 17:00

add a comment


up vote

0

down vote

I managed to get it working by removing the margin and setting placement with relative positioning like:


img.pointer{

    display: block;

    width: 192px;

    height: 11px;

    margin: 211px 0 0 48px;

}

to


img.pointer{

    display: block;

    width: 192px;

    height: 11px;

    position: relative;

    top: 218px;

    left: 50px;

}

I don't have ie7/8 installed but I this works with IE9 compatibility view settings, which showed the misplaced needle in the original fiddle (and it still behaves as expected in Chrome & Firefox).


Try this updated fiddle and let me know if you still have issues: http://jsfiddle.net/6gcS8/4/


shareimprove this answer

answered Dec 7 '12 at 23:07


WebChemist

2,72021726

add a comment

up vote

0

down vote

Doing stuff like rotation or fading in IE7/8 is always likely to have unwanted side effects because it's going beyond the standard capabilities of the browser. In every other browser it's dead easy, but for old IE your jQuery plugin is going to be doing some pretty hacky stuff to make it work. That hacky stuff may work in some cases, but tends to be very brittle and easily broken.


IE's rotation mechanism is very clunky. The described problem of the image being moved up 200 pixels sounds like the rotation centre point may be incorrect. This is something I've encountered a lot when trying to work with rotation in IE. I would have expected your jQuery plugin to deal with that transparently, but if it's getting it wrong then I'm not sure how you'd correct it without bypassing the plugin entirely or using a different image for IE that is 200 pixels taller or something like that.


Re the black border, this may possibly be an issue with handling the alpha channel on the PNG image. You may want to confirm this by using a GIF image instead (although it won't look as good).


But overall, my main recommendation is to avoid doing this kind of thing in old IE entirely. It's just got too many issues to make it worth the effort.


Looking at your jsFiddle example, it seems like you're doing this in order to draw and animate a speedometer-type gauge.


May I suggest an alternative approach which does away with the need to mess around with rotating DOM elements entirely.


There is a Javascript library called Raphael, which draws vector graphics. It works in all browsers, including old IE versions. It is very easy to draw a good looking speedo gauge using Raphael. In fact, I provided a 4-line JS script in another answer here on SO to do exactly that. See here: Drawing a half gauge/speedometer (JavaScript Canvas or Java Swing Example needed). You could take that script, modify it to use your existing gauge background image, and bingo, a working speedo gauge in all browsers, without any of the bugs involved in trying to make IE do things is isn't designed for.


Hope that helps.


转载于:https://my.oschina.net/yonghan/blog/475486

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/263124.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

重构机房收费系统(二)

接上篇《机房收费系统重构&#xff08;一&#xff09;》 二、概要设计 完成了用例图&#xff0c;并用结合用例图完善了一下需求分析说明书&#xff0c;忘记是第几次修订需求分析说明书。有了用例图&#xff0c;很自然就进入了概要设计阶段。我认为这一阶段就是结合包图解决系统…

《Windows核心编程》学习笔记(9)– 在win7或者vista系统下提升一个进程的运行权限...

win7或者vista默认运行程序是在受限制的环境下运行的&#xff0c;以减轻病毒对于系统的破坏。那么我们怎样才能提升一个进程的权限以至让它在 管理员模式下运行。当然CreateProcess函数没有提供这个功能。相反我们需要调用的是ShellExecuteEx函数&#xff1a; BOOL ShellExecu…

2015第29周二AOP

1、问题&#xff1a;想要添加日志记录、性能监控、安全监测 2、最初解决方案2.1、最初解决方案&#xff1a;在每个需要的类函数中重复写上面处理代。 缺点&#xff1a;太多重复代码&#xff0c;且紧耦合2.2、抽象类进行共性设计&#xff0c;子类进行个性设计&#xff0c;此处不…

Docker-compose配置Mysql,Redis,MongoDB

Docker-compose下配置Mysql&#xff0c;Redis&#xff0c;MongoDB详解一、docker-compose简介二、构建一个实例项目1.前后端实现2.Dockerfile及docker-compose.yml3. 生成镜像三、实例程序源码一、docker-compose简介 Compose是用于定义和运行多容器Docker应用程序的工具。通过…

使用WebDeployment Project改善VS2005发布网站问题

VS2005发布网站时不会像VS2003一样生成规则的DLL文件、而生成的DLL文件名含有随机数且不能一个项目生成一个DLL文件、让人有一些遗憾、为了做到像vs2003一样&#xff0c;微软发布了WebDeployment Project插件可解决此问题&#xff1a;下载地址1、下载后安装、右键选择vs2005中的…

Linux、Windows、Mac下Docker的安装与使用

Linux、Windows、Mac下Docker的安装与使用一、Linux下的安装二、Windows与Mac下的安装三、Docker的使用一、Linux下的安装 这里以Centos 7为例&#xff0c;首先&#xff0c;确保系统已经正确运行了Centos 7并已经联网。yum安装gcc环境 yum -y install gcc yum -y install gcc…

[智能架构系列]什么是Buddy智能开发框架

buddy框架&#xff0c;秉承国内优秀框架THINKPHP的优点并增加了很多的商业特性和集成了全版本的商业项目模块&#xff0c;提供给创业者一个最好的选择 组建图: 转载于:https://www.cnblogs.com/scotoma/archive/2011/10/17/2215553.html

Docker Swarm建立服务器集群

Docker Swarm建立服务器集群一、Docker Swarm简介1. 集群模式2. 管理节点--Manager二、Docker Swarm的配置及使用三、Docker Service向集群中添加服务四、Docker Stack部署集群一、Docker Swarm简介 1. 集群模式 这是Docker官网给出的一张swarm原理图&#xff0c;即swarm就是…

python常用魔法函数

1、__init__(): 所有类的超类object&#xff0c;有一个默认包含pass的__init__()实现&#xff0c;这个函数会在对象初始化的时候调用&#xff0c;我们可以选择实现&#xff0c;也可以选择不实现&#xff0c;一般建议是实现的&#xff0c;不实现对象属性就不会被初始化&#xff…

苹果MAC系统的安装

搞Iphone开发&#xff0c;没有苹果系统是不行的。由于我已经装好了苹果的雪豹系统&#xff0c;所以在此我只是简单在说一下大休怎么装&#xff01; 苹果系统&#xff0c;现下在非苹果机上的安装分两种&#xff1a;1、虚拟机安装&#xff1b;2、物理机安装。 现在先说延续一种&a…

sphinx和coreseek

sphinx是国外的一款搜索软件。 coreseek是在sphinx的基础上&#xff0c;增加了中文分词功能&#xff0c;换句话说&#xff0c;就是支持了中文。 Coreseek发布了3.2.14版本和4.1版本&#xff0c;其中的3.2.14版本是2010年发布的&#xff0c;它是基于Sphinx0.9.9搜索引擎的。而4.…

Spring security/Shiro ---登陆成功后返回登陆前界面<页面重定向>

Spring security ---登陆成功后返回登陆前界面<页面重定向>问题&#xff1a;在登陆/退出成功后&#xff0c;我们往往通过http.formLogin().successForwardUrl()和http.logout().logoutSuccessUrl()设定操作成功后的回跳页面。我们现在希望在任意界面跳转到登陆界面后&…

针对plsql developer使用做的三个小设置

来自&#xff1a;http://www.cnblogs.com/william-lee/archive/2010/12/08/1900176.html 1、原来大家在sql窗口写多条sql语句&#xff0c;如果点击“执行”&#xff0c;那么会执行窗口下的所有语句&#xff0c;如果向执行所要的语句&#xff0c;必须选定它。 那么&#xff0c;有…

今天将Notebook还原了, 第一次外加了外围电路

因为天气太热了, 我的Aspire 5502出了问题, 用Ghost还原中途死机, 找了问题原来是太热了....又在宿舍, 没有空调, 又不想去图书馆, 最后就问奶仔借了部风扇, 总算搞掂了...相机太快了....看上去风扇好像停了....不仅有风扇, 它还要裸跑才能胜利还原....温度一高就自动关机了...…

VMware开启NAT模式/仅主机模式后主机ping不通虚拟机的问题

VMware开启NAT模式/仅主机模式后主机ping不通虚拟机的问题问题&#xff1a;VMware设置网络模式为NAT模式后&#xff0c;我们使用主机ping虚拟机无法联通&#xff0c;用虚拟机ping主机可以联通。 原因&#xff1a;这是由于虚拟机的IP网段与主机的VMnet8网段不一致所造成的。 解…

OO设计原则总结

什么是设计原则&#xff1f; 设计原则是基本的工具&#xff0c;应用这些规则可以使你的代码更加灵活、更容易维护&#xff0c;更容易扩展。 基本原则封装变化Encapsulate what varies. 面向接口编程而非实现 Code to an interface rather than to an implementation.优先使用组…

kubectl get node运行时出现:Unable to connect to the server: x509: certificate signed by unknown authority

kubectl get nodes运行时出现&#xff1a;Unable to connect to the server: x509: certificate signed by unknown authority原因&#xff1a;我们在运行kubeadm reset时&#xff0c;没有删除原先的$HOME/.kube文件导致新建的kubelet报错。实际上在kubeadm reset执行后&#x…

POJ 1966 Cable TV Network (最大流最小割)

$ POJ~1966~Cable~TV~Network $ $ solution: $ 第一眼可能让人很难下手&#xff0c;但本就是冲着网络流来的&#xff0c;所以我们直接一点。这道题我们要让这个联通图断开&#xff0c;那么势必会有两个点变得不连通&#xff0c;这道题的数据范围很小&#xff0c;所以我们试着暴…

harbor安装时出现ERROR: An HTTP request took too long to complete. Retry with --verbose to obtain debug in

harbor安装时出现ERROR: An HTTP request took too long to complete. Retry with --verbose to obtain debug information.If you encounter this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value current val…

配置msdtc

配置msdtc需要分别配置数据库服务器和开发机&#xff0c;因为只有两个机器都配置正确了&#xff0c;分布式事务才不会报乌七八糟的错误。如果数据库服务器和开发机是同一台机器&#xff0c;那就不用看本文了&#xff0c;因为不存在分布式事务的问题。 数据库服务器和开发机中配…