jquery css div 图像不出现

发布于 2024-11-04 03:18:24 字数 2006 浏览 0 评论 0原文

我对文档加载时有这样的请求:

   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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

超可爱的懒熊 2024-11-11 03:18:24

尝试从 #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.

看春风乍起 2024-11-11 03:18:24

如果您尝试将图像加载到彼此之上,则需要对它们应用样式,而不仅仅是它们的容器。尝试:

 #container img {
    background: transparent;
    left: 5px;
    top: 20px;
    position: relative;
    border: 1px dotted #ddd;    
    }

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:

 #container img {
    background: transparent;
    left: 5px;
    top: 20px;
    position: relative;
    border: 1px dotted #ddd;    
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文