Jua*_*ego 3 jquery google-chrome width
我不知道发生了什么,但我有这样的菜单设置
<div class="indice_item activo">
<div class="indice_item">
<div class="indice_item">
<div class="indice_item">
<div class="indice_item">
<div id="puntero" style="width: 180px; height: 19px; top: 70px; left: 0px; background-color: rgb(10, 173, 247);"> </div>
Run Code Online (Sandbox Code Playgroud)
问题是div.puntero是一个div,当它悬停在不同的indice_item上时跟随鼠标.我用jquery做它,它的功能是动画的.当页面加载时会创建这个div.puntero,它会查找此菜单的第一项并获取宽度和顶部和左侧坐标,因此它可以在具有类activo的项目下设置div.puntero.
这是执行此操作的代码
/*
* Seleccionado el primero activo
*/
$(document).ready(function() {
$('div.indice_item').last().after('<div id="puntero"> </div>');
//seteamos el puntero donde debe estar
ancho=$('div.indice_item').first().width()
alert(ancho);
$('#puntero').width($('div.indice_item').first().width());
$('#puntero').height(($('div.indice_item').first().height()+3));
$('#puntero').css({
"top" : $('div.indice_item').position().top,
"left" : $('div.indice_item').position().left
});
$('.indice_item').each(function (){
//$(this).
});
});
Run Code Online (Sandbox Code Playgroud)
这在firefox中完美运行,但在chrome中我有几个问题,它似乎工作正常.但后来我按下重装或F5并且div.puntero的宽度变得疯狂.我添加了警报(ancho); 对于宽度,当我进入页面时,它给我正确的宽度180,当我按下重新加载1665或1649时,图表.它为什么这样工作?
小智 6
尝试在加载所有内容后设置高度和宽度,即使用$(window).load(function() {//set height and width here});.
我相信它似乎在firefox中工作正常,因为缓存.也许我错了,只需设置jsFiddle.指出问题要容易得多.
| 归档时间: |
|
| 查看次数: |
4328 次 |
| 最近记录: |