Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Tumblr样式用户卡_Javascript_Jquery_Css_Ajax - Fatal编程技术网

Javascript Tumblr样式用户卡

Javascript Tumblr样式用户卡,javascript,jquery,css,ajax,Javascript,Jquery,Css,Ajax,大家好,我对ajax hover有一个问题。我正在尝试制作一个像tumblr这样的用户悬停卡。但是当我将鼠标悬停动画与ajax一起使用时,它不起作用 这在没有ajax-only css的情况下运行。在本演示中,您可以看到当您将图像悬停时,。p-tooltip将以动画效果打开 但是,如果您在“我的测试”页面中单击此,则您可以看到当您将图像悬停时,将出现。p-tooltip将不会以动画效果打开 HTML 下面是CSS代码: .summary { margin: 50px auto 0; wi

大家好,我对ajax hover有一个问题。我正在尝试制作一个像tumblr这样的用户悬停卡。但是当我将鼠标悬停动画与ajax一起使用时,它不起作用

这在没有ajax-only css的情况下运行。在本演示中,您可以看到当您将图像悬停时,
。p-tooltip
将以动画效果打开

但是,如果您在“我的测试”页面中单击此,则您可以看到当您将图像悬停时,将出现
。p-tooltip
将不会以动画效果打开

HTML

下面是CSS代码:

.summary {
  margin: 50px auto 0;
  width: 50px;
  height: 50px;
  position: relative;
}
.profile-ava {
  width: 50px;
  height: 50px;
  background-image: url(http://gravatar.com/avatar/3913c4e14034c0a7f28db2c632290c21?s=80);
  border-radius: 3px;
  background-size: 50px 50px;
  display: block;
}

.summary a:hover:before {
  content: '';
  position: absolute;
  display: block;
  bottom: -10px;
  left: 0;
  height: 10px;
  width: 100%;
  z-index: 2;
}


.p-tooltip {
  position: absolute;
  margin-top: 10px;
  top: 100%;
  left: 50%;
  margin-left: -140px;
  width: 280px;
  max-height: 120px;
  border-radius: 5px;
  overflow: hidden;
  background-color: #F0F0F0;
  visibility: hidden;
  opacity: 0;
  transition: all 0.5s ease;
}
.profile-header {
  height: 120px;
  background-image: url(https://pbs.twimg.com/profile_banners/571038694/1395748220/1500x500);
  background-size: auto 120px;
  background-position: 50%;
}
.profile-navigation {
  position: absolute;
  top: 0;
  left: 0;
  padding: 10px;
  width: 100%;
  box-sizing: border-box;
}
.profile-nick {
  color: #fff;
  margin: 0;
  padding: 0.4em 0;
  font-size: 0.8em;
  font-weight: bold;
}
.profile-action {
  float: right;
  background-color: #eee;
  padding: 0.4em;
  border-radius: 2px;
  color: inherit;
  text-decoration: none;
  font-size: 0.8em;
  font-weight: bold;
}


.p-tooltip .profile-ava {
  margin: -40px auto 0;
  width: 80px;
  height: 80px;
  background-size: 80px;
  border: 3px solid #F0F0F0;
  border-radius: 5px;
}

.profile-info {
  text-align: center;
  padding: 10px;
  opacity: 0;
}
.profile-title {font-size: 1.6em; margin: 0;}
.profile-description {
  margin: 0;
  font-size: 0.8em;
}

.profile-items {margin: 0px; padding: 10px;}
.profile-items:after {
  content: '';
  display: table;
  clear: both;
}
.profile-items li {  
  width: 80px;
  height: 80px;
  background-size: cover;
  background-position: center;
  float: left;
  display: block;
  border-radius: 3px;
}
.profile-items li:not(:first-child) {margin-left: 10px;}
.profile-items li:nth-child(1) {
  background-image: url(https://o.twimg.com/1/proxy.jpg?t=FQQVBBgwaHR0cHM6Ly9pLnl0aW1nLmNvbS92aS9CM3lna2lYRXVyWS9ocWRlZmF1bHQuanBnFAIWABIA&s=z1wybbbNHF0pyLthl3xhxVBNjbYlAEWEzPd-dUtrWOY);
}
.profile-items li:nth-child(2) {
  background-image: url(https://pbs.twimg.com/media/B7pkXfgCIAAwoY0.jpg:thumb);
}
.profile-items li:nth-child(3) {
  background-image: url(https://pbs.twimg.com/media/B7A3NHjIIAIt6eg.png:large);
}


.profile-header {
  -webkit-transform: translate(0, -50px);
  -moz-transform: translate(0, -50px);
  transform: translate(0, -50px);

  -webkit-transition: all 0.2s ease-out;
  -moz-transition: all 0.2s ease-out;
  transition: all 0.2s ease-out;

  -webkit-transition-delay: 0.1s;
  -moz-transition-delay: 0.1s;
  transition-delay: 0.1s;

  opacity: 0;
}
.profile-info {
  -webkit-transform: translate(0, 50px);
  -moz-transform: translate(0, 50px);
  transform: translate(0, 50px);

  -webkit-transition: all 0.3s ease-out;
  -moz-transition: all 0.3s ease-out;
  transition: all 0.3s ease-out;

  -webkit-transition-delay: 0.1s;
  -moz-transition-delay: 0.1s;
  transition-delay: 0.1s;
}
.p-tooltip .profile-ava {
  -webkit-transform: scale(0.5) translate(0, -10px);
  -moz-transform: scale(0.5) translate(0, -10px);
  transform: scale(0.5) translate(0, -10px);

  -webkit-transition: all 0.5s ease-out;
  -moz-transition: all 0.5s ease-out;
  transition: all 0.5s ease-out;

  -webkit-transition-delay: 0.1s;
  -moz-transition-delay: 0.1s;
  transition-delay: 0.1s;

  opacity: 0;
}
.profile-items li {
  -webkit-transform: translate(0, 50px);
  -moz-transform: translate(0, 50px);
  transform: translate(0, 50px);

  -webkit-transition: all 0.3s ease-out;
  -moz-transition: all 0.3s ease-out;
  transition: all 0.3s ease-out;

  -webkit-transition-delay: 0.3s;
  -moz-transition-delay: 0.3s;
  transition-delay: 0.3s;
  opacity: 0;
}
.profile-items li:nth-child(2) {
  -webkit-transition-delay: 0.35s;
  -moz-transition-delay: 0.35s;
  transition-delay: 0.35s;
}
.profile-items li:nth-child(3) {
  -webkit-transition-delay: 0.4s;
  -moz-transition-delay: 0.4s;
  transition-delay: 0.4s;
}


.summary:hover .p-tooltip {
  visibility: visible;
  opacity: 1;
  max-height: 600px;
}
.summary:hover .profile-header,
.summary:hover .profile-info,
.summary:hover .p-tooltip .profile-ava,
.summary:hover .profile-items li {
  -webkit-transform: translate(0,0) scale(1);
  -moz-transform: translate(0,0) scale(1);
  transform: translate(0,0) scale(1);
  opacity: 1;
}

任何人都可以帮我

当您显示卡时,它只包含加载消息。当内容到达并放入卡片时,这不是CSS更改,因此转换不会被激活


如果您等到内容到达后才显示卡片,则需要制作动画。

基本上,我已经创建了一个非常聪明的解决方法。它是一个遮罩,覆盖图像(不可见),直到加载html,然后在降低z索引后进行悬停css。悬停javascript位于容器上

HTML


JS

var response='

Username

Lorem Ipsum只是印刷和排版行业的虚拟文本。Lorem Ipsum一直是业界的标准假人。

    • ”; $(文档).ready(函数(){ 函数ShowProfile工具提示(e,id){ //从get_profile.php发送id和获取信息 $.ajax({ url:“/echo/html/”, 数据:{ 答:, 延迟:0 }, 方法:“post”, 成功:函数(返回HTML){ e、 查找('.user container').html(returnHtml).promise().done(函数(){ $('.the container').addClass('loaded'); }); } }); } 函数hideProfileTooltip(){ $('.the container').removeClass('loaded'); } $('.the container').hover(函数(e){ var id=$(this.find('.summary').attr('data-id'); showProfileTooltip($(此),id); },函数(){ hideProfileTooltip(); }); });
悬停时,使用jQuery更改工具提示的CSS。不要这样做。看看这个。由于我无法访问您的get_profile.php页面,因此我无法帮助您进行ajax调用。我还删除了一些不必要的代码。试试小提琴,看看它是否有效。@Preetesh.Dev啊,我知道这一点,我想我需要调用css。如果没有
e.append($('.p-tooltip').css({'top':'20','left':80')),它将无法工作确切地说,没有
e.append
,什么是不起作用的?你的问题是关于动画的,如果你删除了不必要的代码,效果会很好。@Preetesh.Dev当你悬停在图像上时,ajax会调用id为的用户信息。id是用户id。如果我删除
e.append($('.p-tooltip').css({'top':'20','left':80')).show()然后.p-工具提示现在将显示在图片底部。@Preetesh.Dev我更新了我的问题有一个
now@innovation:放置
e.append($('.p-tooltip').css({top:'20',left:'80')).show()
$('.p-tooltip').html(html)之后。一切都是一样的,没有任何变化。@innovation:啊哈,也是加载消息弄乱了动画。如果只是删除加载消息,则动画效果良好。考虑在加载消息中使用不同的元素,或者在将加载的内容放入元素之前隐藏加载消息。http://localhost:8888/get_profile.php?uid=undefined&html=%3Cdiv+类%3D%22p工具提示%2……Fdiv%3E&delay=0
我的php部分没有问题。这里有什么问题?请仔细检查此行是否正确:
varid=$(this).find('.summary').attr('data-id')我甚至会将其更改为
varid=$(this).find('.summary').data('id')如何在发送前添加加载动画?我想添加我的加载动画。这就是我想添加的内容:我仍然尝试添加这个加载div,但当我将任何图像悬停在
.ajax loader
显示所有图像时,它都不起作用亲爱的朋友,你能帮我回答这个问题吗:
$(document).ready(function() { 

        function showProfileTooltip(e, id){ 
           e.append($('.p-tooltip').css({ 
             'top':'20', 
             'left':'80' 
             }).show()); 
            //send id & get info from get_profile.php 
             $.ajax({
             url: 'get_profile.php?uid='+id,
             beforeSend: function(){

             $('.p-tooltip').html('Loading..');
             },
             success: function(html){ 
             $('.p-tooltip').html(html); 
             } 
           }); 
         } 

        function hideProfileTooltip(){ 
        $('.p-tooltip').hide().fadeIn('fast'); 
         } 
        $('.summary a').hover(function(e){ 

          var id = $(this).attr('data-id'); 
          showProfileTooltip($(this), id); 

          }, function(){ 
          setTimeout(function(){ 
          hideProfileTooltip(); 
          },2000); 
         });
    });
.summary {
  margin: 50px auto 0;
  width: 50px;
  height: 50px;
  position: relative;
}
.profile-ava {
  width: 50px;
  height: 50px;
  background-image: url(http://gravatar.com/avatar/3913c4e14034c0a7f28db2c632290c21?s=80);
  border-radius: 3px;
  background-size: 50px 50px;
  display: block;
}

.summary a:hover:before {
  content: '';
  position: absolute;
  display: block;
  bottom: -10px;
  left: 0;
  height: 10px;
  width: 100%;
  z-index: 2;
}


.p-tooltip {
  position: absolute;
  margin-top: 10px;
  top: 100%;
  left: 50%;
  margin-left: -140px;
  width: 280px;
  max-height: 120px;
  border-radius: 5px;
  overflow: hidden;
  background-color: #F0F0F0;
  visibility: hidden;
  opacity: 0;
  transition: all 0.5s ease;
}
.profile-header {
  height: 120px;
  background-image: url(https://pbs.twimg.com/profile_banners/571038694/1395748220/1500x500);
  background-size: auto 120px;
  background-position: 50%;
}
.profile-navigation {
  position: absolute;
  top: 0;
  left: 0;
  padding: 10px;
  width: 100%;
  box-sizing: border-box;
}
.profile-nick {
  color: #fff;
  margin: 0;
  padding: 0.4em 0;
  font-size: 0.8em;
  font-weight: bold;
}
.profile-action {
  float: right;
  background-color: #eee;
  padding: 0.4em;
  border-radius: 2px;
  color: inherit;
  text-decoration: none;
  font-size: 0.8em;
  font-weight: bold;
}


.p-tooltip .profile-ava {
  margin: -40px auto 0;
  width: 80px;
  height: 80px;
  background-size: 80px;
  border: 3px solid #F0F0F0;
  border-radius: 5px;
}

.profile-info {
  text-align: center;
  padding: 10px;
  opacity: 0;
}
.profile-title {font-size: 1.6em; margin: 0;}
.profile-description {
  margin: 0;
  font-size: 0.8em;
}

.profile-items {margin: 0px; padding: 10px;}
.profile-items:after {
  content: '';
  display: table;
  clear: both;
}
.profile-items li {  
  width: 80px;
  height: 80px;
  background-size: cover;
  background-position: center;
  float: left;
  display: block;
  border-radius: 3px;
}
.profile-items li:not(:first-child) {margin-left: 10px;}
.profile-items li:nth-child(1) {
  background-image: url(https://o.twimg.com/1/proxy.jpg?t=FQQVBBgwaHR0cHM6Ly9pLnl0aW1nLmNvbS92aS9CM3lna2lYRXVyWS9ocWRlZmF1bHQuanBnFAIWABIA&s=z1wybbbNHF0pyLthl3xhxVBNjbYlAEWEzPd-dUtrWOY);
}
.profile-items li:nth-child(2) {
  background-image: url(https://pbs.twimg.com/media/B7pkXfgCIAAwoY0.jpg:thumb);
}
.profile-items li:nth-child(3) {
  background-image: url(https://pbs.twimg.com/media/B7A3NHjIIAIt6eg.png:large);
}


.profile-header {
  -webkit-transform: translate(0, -50px);
  -moz-transform: translate(0, -50px);
  transform: translate(0, -50px);

  -webkit-transition: all 0.2s ease-out;
  -moz-transition: all 0.2s ease-out;
  transition: all 0.2s ease-out;

  -webkit-transition-delay: 0.1s;
  -moz-transition-delay: 0.1s;
  transition-delay: 0.1s;

  opacity: 0;
}
.profile-info {
  -webkit-transform: translate(0, 50px);
  -moz-transform: translate(0, 50px);
  transform: translate(0, 50px);

  -webkit-transition: all 0.3s ease-out;
  -moz-transition: all 0.3s ease-out;
  transition: all 0.3s ease-out;

  -webkit-transition-delay: 0.1s;
  -moz-transition-delay: 0.1s;
  transition-delay: 0.1s;
}
.p-tooltip .profile-ava {
  -webkit-transform: scale(0.5) translate(0, -10px);
  -moz-transform: scale(0.5) translate(0, -10px);
  transform: scale(0.5) translate(0, -10px);

  -webkit-transition: all 0.5s ease-out;
  -moz-transition: all 0.5s ease-out;
  transition: all 0.5s ease-out;

  -webkit-transition-delay: 0.1s;
  -moz-transition-delay: 0.1s;
  transition-delay: 0.1s;

  opacity: 0;
}
.profile-items li {
  -webkit-transform: translate(0, 50px);
  -moz-transform: translate(0, 50px);
  transform: translate(0, 50px);

  -webkit-transition: all 0.3s ease-out;
  -moz-transition: all 0.3s ease-out;
  transition: all 0.3s ease-out;

  -webkit-transition-delay: 0.3s;
  -moz-transition-delay: 0.3s;
  transition-delay: 0.3s;
  opacity: 0;
}
.profile-items li:nth-child(2) {
  -webkit-transition-delay: 0.35s;
  -moz-transition-delay: 0.35s;
  transition-delay: 0.35s;
}
.profile-items li:nth-child(3) {
  -webkit-transition-delay: 0.4s;
  -moz-transition-delay: 0.4s;
  transition-delay: 0.4s;
}


.summary:hover .p-tooltip {
  visibility: visible;
  opacity: 1;
  max-height: 600px;
}
.summary:hover .profile-header,
.summary:hover .profile-info,
.summary:hover .p-tooltip .profile-ava,
.summary:hover .profile-items li {
  -webkit-transform: translate(0,0) scale(1);
  -moz-transform: translate(0,0) scale(1);
  transform: translate(0,0) scale(1);
  opacity: 1;
}
.summary {
    margin: -50px auto 0;
    width: 50px;
    height: 50px;
    position: relative;
    z-index: 0;
}
.summary-mask {
    margin: 50px auto 0;
    width: 50px;
    height: 50px;
    position: relative;
    z-index: 1;
}
.loaded .summary-mask {
    z-index: -1;
}
<div class="the-container">
    <div class="summary-mask"></div>
    <div class="summary" data-id="100"> <a href="http://kraigo.tumblr.com/" class="profile-ava"></a>

        <div class="user-container"></div>
    </div>
</div>
var response = '<div class="p-tooltip"> <div class="profile-header"></div> <div class="profile-navigation"> <a href="http://kraigo.tumblr.com/" class="profile-action">Follow</a> <p class="profile-nick"> <a href="http://kraigo.tumblr.com/">Page Name</a> </p> </div> <div class="profile-ava"></div> <div class="profile-info"> <h1 class="profile-title">Username</h1> <p class="profile-description">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy ..</p> </div> <ul class="profile-items"> <li></li> <li></li> <li></li> </ul> </div>';

$(document).ready(function () {

    function showProfileTooltip(e, id) {
        //send id & get info from get_profile.php 
        $.ajax({
            url: '/echo/html/',
            data: {
                html: response,
                delay: 0
            },
            method: 'post',
            success: function (returnHtml) {
                e.find('.user-container').html(returnHtml).promise().done(function () {
                    $('.the-container').addClass('loaded');
                });
            }
        });

    }

    function hideProfileTooltip() {
        $('.the-container').removeClass('loaded');
    }
    $('.the-container').hover(function (e) {

        var id = $(this).find('.summary').attr('data-id');
        showProfileTooltip($(this), id);

    }, function () {
        hideProfileTooltip();
    });
});