简体   繁体   English

悬停实现时图像上的文字

[英]Text on image on hover implementation

I'm using the following code on the link for a slide show in my portfolio. 我在链接中使用以下代码进行我的投资组合中的幻灯片放映。 It has a section for a photo, another one for a title, and another one for an accompanying story. 它的一部分用于拍摄照片,另一部分用于标题,另一部分用于故事。 They all change with next and prev buttons at the same time. 它们都同时通过下一个和上一个按钮更改。 I'm trying to get the story text show up when mouse hovers over the image. 我试图让鼠标悬停在图像上时显示故事文本。 I've been trying to implement various codes I found online but couldn't achieve a result so far. 我一直在尝试实现我在网上找到的各种代码,但到目前为止仍未实现结果。 When I try, either the images never show up or the stories never show up and I couldn't find a way around. 当我尝试时,要么图像不显示,要么故事不显示,所以我找不到解决方法。 The type of effect I'm looking for would be the one in the middle of the left side of the screen on this link; 我要寻找的效果类型将是此链接在屏幕左侧中间的效果。 http://tympanus.net/jCapSlide/ http://tympanus.net/jCapSlide/

I am wondering if anyone knows how to implement this animation to my code. 我想知道是否有人知道如何在我的代码中实现此动画。 And I also want to keep the other sections like the title section functioning the same. 我还希望其他部分(例如标题部分)保持相同的功能。

Here is the code I'm using at the moment; 这是我目前正在使用的代码; http://jsfiddle.net/elliotgray/64nfP/ http://jsfiddle.net/elliotgray/64nfP/

And below is the code that is used to create hover text animation on the link above in case it might be useful. 下面是用于在上面的链接上创建悬停文本动画的代码,以防它可能有用。 This is from the downloaded code from their site. 这是从他们的站点下载的代码。

Any help would be appreciated. 任何帮助,将不胜感激。

(function($) {
    $.fn.capslide = function(options) {
        var opts = $.extend({}, $.fn.capslide.defaults, options);
        return this.each(function() {
            $this = $(this);
            var o = $.meta ? $.extend({}, opts, $this.data()) : opts;

            if(!o.showcaption)  $this.find('.ic_caption').css('display','none');
            else $this.find('.ic_text').css('display','none');

            var _img = $this.find('img:first');
            var w = _img.css('width');
            var h = _img.css('height');
            $('.ic_caption',$this).css({'color':o.caption_color,'background-color':o.caption_bgcolor,'bottom':'0px','width':w});
            $('.overlay',$this).css('background-color',o.overlay_bgcolor);
            $this.css({'width':w , 'height':h, 'border':o.border});
            $this.hover(
                function () {
                    if((navigator.appVersion).indexOf('MSIE 7.0') > 0)
                    $('.overlay',$(this)).show();
                    else
                    $('.overlay',$(this)).fadeIn();
                    if(!o.showcaption)
                        $(this).find('.ic_caption').slideDown(500);
                    else
                        $('.ic_text',$(this)).slideDown(500);   
                },
                function () {
                    if((navigator.appVersion).indexOf('MSIE 7.0') > 0)
                    $('.overlay',$(this)).hide();
                    else
                    $('.overlay',$(this)).fadeOut();
                    if(!o.showcaption)
                        $(this).find('.ic_caption').slideUp(200);
                    else
                        $('.ic_text',$(this)).slideUp(200);
                }
            );
        });
    };
    $.fn.capslide.defaults = {
        caption_color   : 'white',
        caption_bgcolor : 'black',
        overlay_bgcolor : 'blue',
        border          : '1px solid #fff',
        showcaption     : true
    };
})(jQuery);

Thank you! 谢谢!

I alter your code. 我更改您的代码。

http://jsfiddle.net/64nfP/3/ http://jsfiddle.net/64nfP/3/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM