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 感谢您的浏览。
I have this request for when the document loads:
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
);
}
);
This if statement which I will add to when I get something working correctly:
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'
});
And this CSS:
<style>
#container {
background: transparent;
left: 5px;
top: 20px;
position: relative;
border: 1px dotted #ddd;
}
</style>
And then this in the body:
<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>
Because I am trying to load 5 images on top of each other to make it appears as though they are one image. They are grayed out when the document loads. Then as the user slides their finger across the image the images are animated to their normal state. But nothing is appearing. Does anyone know why? http://tinyurl.com/62hakh2 Thanks for looking.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试从
#swipe-frame
div 中删除height:100%
,因为这会使 div 占据整个屏幕,并且#container
div 将紧随其后。Try removing the
height:100%
from the#swipe-frame
div, since this will make the div occupy the whole screen and the#container
div will be just after it.如果您尝试将图像加载到彼此之上,则需要对它们应用样式,而不仅仅是它们的容器。尝试:
If you're trying to load the images on top each other, you'll need to apply a style to them, not just their container. Try: