jQuery的CSS DIV图像不会出现
问题描述:
我的文档加载时,此请求:jQuery的CSS DIV图像不会出现
jQuery(window).load(
function(){
$('#container img').animate({"opacity": 1});
$('#container img').hover(function() {
$(this).stop().animate({ "opacity": .5 });
}, function() {
$(this).stop().animate({ "opacity": 1 });
});
setTimeout(
function(){
window.scrollTo(0, 0);
},
50
);
}
);
这个if语句,我会增加,当我得到的东西正常工作:
function touchMove(event) {
event.preventDefault();
if ((event.touches.length === 1) && (swipeDirection === 'down') && (swipeLength >= 90) && (swipeLength <= 120)) {
curX = event.touches[0].pageX;
curY = event.touches[0].pageY;
('1.png').hover(function() {
$(this).stop().animate({
"opacity": '1'
});
而这个CSS:
<style>
#container {
background: transparent;
left: 5px;
top: 20px;
position: relative;
border: 1px dotted #ddd;
}
</style>
然后这个在身体:
<div id="swipe-frame" class="swipe-element" ontouchstart="touchStart(event,'swipe-frame');" ontouchend="touchEnd(event);" ontouchmove="touchMove(event);" ontouchcancel="touchCancel(event);" style="width:100%; height:100%; background: transparent; -webkit-user-select: none;padding-top:128px;">
</div>
<div id="container">
<img src="1.png" alt="image" />
<img src="2.png" alt="image" />
<img src="3.png" alt="image" />
<img src="4.png" alt="image" />
<img src="5.png" alt="image" />
</div>
因为我试图加载5个图像在彼此的顶部,使它看起来好像他们是一个图像。文档加载时它们变灰。然后,当用户在图像上滑动手指时,图像被激活为正常状态。但没有出现。有谁知道为什么? http://tinyurl.com/62hakh2感谢您的期待。
答
尝试从#swipe-frame
DIV取出height:100%
,因为这会令DIV占据整个屏幕,只是它后#container
格会。
答
如果您尝试将图像彼此放在一起,您需要为它们应用样式,而不仅仅是它们的容器。尝试:
#container img {
background: transparent;
left: 5px;
top: 20px;
position: relative;
border: 1px dotted #ddd;
}
当我从高度和宽度中删除100%没有出现。只是一个白色的屏幕。 – dmccallum 2011-04-28 23:31:59