首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >滑动标题根据图像大小在caption.resizing中放置小部件div

滑动标题根据图像大小在caption.resizing中放置小部件div
EN

Stack Overflow用户
提问于 2015-02-18 23:50:54
回答 1查看 61关注 0票数 0

我想要一张有两个标题的图片。一个会从顶部滑落,另一个会从底部滑动。我想得到它们相对于图像的大小(如此动态地改变到图像的大小),它们中的每一个都覆盖了图像的25%。

目前,我有一个从左向上滑动,但我需要它从顶部向下滑动,底部的一个也从左边滑行,但我需要它从底部滑行。

这是小提琴:http://jsfiddle.net/s4qvL5cf/1/

代码语言:javascript
复制
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
    <title>review image system</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" media="screen" href="style.css" />
    <script src="modernizr.custom.js"></script>
    <script src="jquery.js"></script>
    <script src="newjavascript.js"></script>
    <script src="toucheffects.js"></script>
</head>

<body>
<div class="wrapper">

    <header>
        <h1 class="main_head">blub</h1>

    </header>
    <hr />

        <div class="container left">

            <img src="http://placehold.it/350x150" alt="image" />
            <article class="text css3-4">
                    <h1><a href="#" class="css3-4">space1</a></h1>
            </article>
            <article class="text css3-3 css3-4">
                    <h1><a href="#" class="css3-3 css3-4">space2</a>    </h1>
                    <span><div class='movie_choice'>
                                                            <div id="r1" class="rate_widget">
                                                           <div class="star_1 ratings_stars"></div>
                                                            <div class="star_2 ratings_stars"></div>
                                                            <div class="star_3 ratings_stars"></div>
                                                            <div class="star_4 ratings_stars"></div>
                                                             <div class="star_5 ratings_stars"></div>
                                                             <div class="total_votes">vote data</div>
                                                              </div>
                                                              </div>
                                                    </span>
            </article>
        </div>

    <hr />

    </div>  

    <script>


// first thing added 
$(document).ready(function() {

    $('.rate_widget').each(function(i) {
        var widget = this;
        var out_data = {
            widget_id : $(widget).attr('id'),
            fetch: 1
        };
        $.post({
            url:'ratings.php',
            data: out_data,
            success:function(INFO) {
                $(widget).data( 'fsr', INFO );
                set_votes(widget);
            },
            dataType:'json'
        });
    });


    $('.ratings_stars').hover(
        // Handles  mouseover
        function() {
            $(this).prevAll().andSelf().addClass('ratings_over');
            $(this).nextAll().removeClass('ratings_vote'); 
        },
        // Handles mouseout
        function() {
            $(this).prevAll().andSelf().removeClass('ratings_over');
            // can't use 'this' because it wont contain the updated data
            set_votes($(this).parent());
        }
    );


    //  records the vote
    $('.ratings_stars').bind('click', function() {
        var star = this;
        var widget = $(this).parent();

        var clicked_data = {
            clicked_on : $(star).attr('class'),
            widget_id : $(star).parent().attr('id')
        };
        $.post(
                {
            url:'ratings.php',
           data: clicked_data,
            success:function(INFO) {
                widget.data( 'fsr', INFO );
                set_votes(widget);
            },
            dataType:'json'
    });



});

function set_votes(widget) {

    var avg = $(widget).data('fsr').whole_avg;
    var votes = $(widget).data('fsr').number_votes;
    var exact = $(widget).data('fsr').dec_avg;

    window.console && console.log('and now in set_votes, it thinks the fsr is ' + $(widget).data('fsr').number_votes);

    $(widget).find('.star_' + avg).prevAll().andSelf().addClass('ratings_vote');
    $(widget).find('.star_' + avg).nextAll().removeClass('ratings_vote'); 
    $(widget).find('.total_votes').text( votes + ' votes recorded (' + exact + ' rating)' );
}

});
</script>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-02-19 01:31:54

有关所需的更改幻灯片,请参见

代码语言:javascript
复制
article.css3-3
{
    top:-80px;
    -webkit-transition: all .5s ease-out;
    -moz-transition: all .5s ease-out;
    -o-transition: all .5s ease-out;
    transition: all .5s ease-out;
    width:400px;
}

.container:hover article.css3-3 {
    top:0;
}

...

article.css3-4
{
    bottom:-80px;
    -webkit-transition: all .5s ease-out;
    -moz-transition: all .5s ease-out;
    -o-transition: all .5s ease-out;
    transition: all .5s ease-out;
    width:400px;
}

.container:hover article.css3-4{
    bottom:0;
}

我测试了删除元素".container“的宽度和高度属性。我认为装载的图像会根据需要增加容器。瞧一瞧

代码语言:javascript
复制
.container {
    ...
    /*height: 200px;*/
    ...
}

.container2 {
    ...
    /*height: 200px;*/
    ...
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28596222

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档