转盘不转动的问题

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,一经查实,立即删除!

相关文章

主机无法连接虚拟机中的redis服务

解决&#xff1a;主机<本地>无法连接虚拟机中的redis服务首先保证虚拟机网络已经和主机网络互通&#xff0c;即相互ping对方IP&#xff0c;能ping通但是仍然连不上redis服务&#xff0c;可能是以下问题。redis服务配置问题 配置redis.conf如下 protected-mode no #关闭…

重构机房收费系统(二)

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

VS 2005 安装一个的小问题

今天通过 添加/删除 安装了VC的部分功能之后&#xff0c;在 程序》Visual Studio 2005 》Visual Studio 2005 Tools 里面竟然找不到 ActiveX Control Test Container 了&#xff0c;但是却有 Spy和 MFC-ATL Trace Tool&#xff0c;建了MFC ActiveX功能在IDE里面 工具 菜单中也找…

《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应用程序的工具。通过…

初学者应该了解的一些SQL语句及hr 用户解锁相关

初学者应该了解的一些SQL语句 1.显示当前连接用户SQL> show user&#xff1b; 2.查看系统拥有哪些用户SQL> select * from all_users; 3.连接到新用户SQL> conn 用户名/密码 4.查询当前用户下所有对象SQL> select * from tab; 5.建立第一个表SQL> create table …

用Delphi 6开发ASP上传组件详解

文件上传是WEB开发中经常要用到的功能&#xff0c;但ASP本身和内置的组件都不支持文件上传功能。网上流传的一些第三方组件虽然能够解决这个问题&#xff0c;但大多是要收费的&#xff0c;更别说Open Source了。本文将详细剖析WEB文件上传的原理&#xff0c;以及一步步指导读者…

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

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

03 - const static extern

const是一个C语言的关键字&#xff0c;它限定一个变量不允许被改变。使用const可以在一定程度上提高程序的安全性和可靠性&#xff0c;再者在看别人的代码作品的时候也可以有助于清晰理解const所起的作用。 1、const和#define的区别 &#xff08;1&#xff09;编译器处理的方式…

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

Mac nginx PCRE install ngnix

1 下载&#xff1a;pcre-8.12.tar.gz ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre 2 sudo tar xvfz pcre-8.12.tar.gz 解压文件 解压完成之后&#xff0c;执行命令 cd pcre-8.12sudo ./configure --prefix/usr/local --enable-utf8 sudo make sudo make instal…

解决IE6下,给图片加上line-height属性不起作用的方法

在css设置中&#xff0c;我们一般用行高line-height来设定某一行的高度&#xff0c;这在ie7与firefox等浏览器都适用。但当行中有其他元素时&#xff08;如图片&#xff0c;SPAN,li..&#xff09;在IE6.0下line-height会不起效果&#xff0c;后来查了下资料&#xff0c;果然如此…

小孔子文章管理系统V2.0发布测试

小孔子文章管理系统V2.0 【感谢】 本系统是仿照nbArticle开发,在此表示感谢nb联盟的作品. 【版权声明】 本软体为开源项目,允许个人使用或修改. 非经小孔子本人授权许可,不得将之用于盈利或非盈利性的商业用途. 欢迎使…

Docker Swarm建立服务器集群

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

Linux下的版本升级只是浮云

ubuntu从11.04到11.10&#xff0c;直接系统升级&#xff0c;那简直是扯蛋啊 gnome 也是 从2.32到了3 &#xff0c;ubuntu从此停在了11.04&#xff0c;对我而言。 转载于:https://www.cnblogs.com/x3d/archive/2011/10/18/2661307.html

恢复快速启动栏里的“显示桌面”图标

在百度知道上看到一个提问&#xff0c;大意是说自己不小心把快速启动栏的“显示桌面”图标给删除了&#xff0c;“显示桌面”按钮是大家经常用到的操作按钮&#xff0c;有时误删除掉后&#xff0c;然后使用起来非常不方便。 因为刚刚帮一个朋友解决了同样的问题&#xff0c;所以…

python常用魔法函数

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

Python3.4 Django MySQL MySQL-python 安装不成功解决办法 Unable to find vcvarsall.bat 错误

解决办法&#xff1a; 1.安装pymysql pip install pymysql 2.在Django项目中找到跟settings.py在同一个目录下的__init__.py 添加如下代码 import pymysql pymysql.install_as_MySQLdb() 然后就解决了 ----------------------------------------------------------------------…