如果对象使用 jQuery 进行动画处理,点状边框将变为实线

发布于 2024-08-14 14:02:46 字数 1707 浏览 1 评论 0原文

我有一个简单的设置:一张图像,然后是一个带有一些隐藏信息的段落,然后在鼠标悬停时在图像上向上滑动。如果我尝试将虚线或点线的顶部边框应用到段落上,它只会变成实线。这是一个已修复的已知问题吗?我什至尝试通过 jQuery 添加虚线边框,但它仍然显示为实线。

HTML:

<div class="wrap">
    <img src="images/fillertxt.jpg" alt="image" />
    <img src="images/filler.jpg" class="front" alt="image" />
    <p class="info">
        This is a short description with a bit of text.
    </p>
</div>

CSS:

.wrap .info {
    width:204px;
    height:50px;
    background:url(images/infobg.jpg) repeat-x #8d9c0c;
    color:#f7f5ef;
    padding:3px;
    position:absolute;
    top:142px;
    left:0;
    border-top:3px dotted #8d9c0c;
}

JS:

$(document).ready(function(){
$("p.info").css("border-top","3px dotted #8d9c0c");
$(function(){
   bindTypeOne();
   $("input[type=radio]").click(function(){
      if ($(this).attr("rel") == "type1"){
         bindTypeOne();
      } else if ($(this).attr("rel") == "type2"){
         bindTypeTwo();
      }
   });
});

function bindTypeOne() { 
 $("div.wrap").hover(function(){
    $(this).children("p.info").stop();
    $(this).children(".front").stop().animate({"top":"141px"}, 400);        
   },function(){
    $(this).children("p.info").stop();
    $(this).children(".front").stop().animate({"top":"0"}, 700);
 });
};

function bindTypeTwo() {
  $("div.wrap").hover(function(){
   $(this).children(".front").stop();
   $(this).children("p.info").stop().animate({"top":"80px","border-top":"3px dotted #8d9c0c"}, 400);        
  },function(){
   $(this).children(".front").stop();
   $(this).children("p.info").stop().animate({"top":"142px"}, 700);
  });
};

});

I have a simple setup: an image and then a paragraph with a bit of info that is hidden and then slides up over the image on mouse hover. If I try to apply a border-top that is dashed or dotted onto the paragraph it simply turns into a solid line. Is this a known issue with a fix? I even tried adding the dotted border through jQuery and it still comes out as a solid line.

HTML:

<div class="wrap">
    <img src="images/fillertxt.jpg" alt="image" />
    <img src="images/filler.jpg" class="front" alt="image" />
    <p class="info">
        This is a short description with a bit of text.
    </p>
</div>

CSS:

.wrap .info {
    width:204px;
    height:50px;
    background:url(images/infobg.jpg) repeat-x #8d9c0c;
    color:#f7f5ef;
    padding:3px;
    position:absolute;
    top:142px;
    left:0;
    border-top:3px dotted #8d9c0c;
}

JS:

$(document).ready(function(){
$("p.info").css("border-top","3px dotted #8d9c0c");
$(function(){
   bindTypeOne();
   $("input[type=radio]").click(function(){
      if ($(this).attr("rel") == "type1"){
         bindTypeOne();
      } else if ($(this).attr("rel") == "type2"){
         bindTypeTwo();
      }
   });
});

function bindTypeOne() { 
 $("div.wrap").hover(function(){
    $(this).children("p.info").stop();
    $(this).children(".front").stop().animate({"top":"141px"}, 400);        
   },function(){
    $(this).children("p.info").stop();
    $(this).children(".front").stop().animate({"top":"0"}, 700);
 });
};

function bindTypeTwo() {
  $("div.wrap").hover(function(){
   $(this).children(".front").stop();
   $(this).children("p.info").stop().animate({"top":"80px","border-top":"3px dotted #8d9c0c"}, 400);        
  },function(){
   $(this).children(".front").stop();
   $(this).children("p.info").stop().animate({"top":"142px"}, 700);
  });
};

});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

錯遇了你 2024-08-21 14:02:46

我认为“border-top”不适用于动画。我知道,要在动画中设置边框宽度,您必须使用 borderWidth 而不是 border-width。所以请尝试同样使用。希望它会有所帮助:)

I don't think "border-top" will work with animation. I know that, to set border width in animation, you have to use borderWidth not border-width. So Please try using likewise. Hope it will help :)

驱逐舰岛风号 2024-08-21 14:02:46

无法重现您所描述的内容(使用 Opera)。

检查这个简单的演示页面http://jsbin.com/ofoya

请提供一个可以重现您的问题的工作示例。并包含您使用的浏览器的信息。

顺便提一句。您是否知道您将 background-colorborder-color 设置为相同的颜色代码?尝试将 border-top:3px dotted #8d9c0c; 更改为 border-top:3px dotted #FF0066;

Can't reproduce what you describe (using Opera).

Check this simple demopage http://jsbin.com/ofoya

Please provide a working sample which reproduces your problem. And include information which browser you use.

Btw. are you aware that you set the background-color and the border-color to the same color code? Try changing border-top:3px dotted #8d9c0c; to e.g. border-top:3px dotted #FF0066;

雪落纷纷 2024-08-21 14:02:46

如果您使用 jquery ui,border-top 确实可以工作,但您需要将其更改为“borderTop”。遗憾的是我发现你必须定义每个边界边

$(this).stop().animate({
    backgroundColor: "#000",
    borderRightColor: "#09c",
    borderLeftColor: "#09c",
    borderTopColor: "#09c",
    borderBottomColor: "#09c"
}, "slow");

border-top does work if you use the jquery ui, but you need to change it to "borderTop". Sadly I have found that you have to define each border side

$(this).stop().animate({
    backgroundColor: "#000",
    borderRightColor: "#09c",
    borderLeftColor: "#09c",
    borderTopColor: "#09c",
    borderBottomColor: "#09c"
}, "slow");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文