javascript - 在动画期间盲目隐藏div

标签 javascript css jquery-ui jquery

我有以下内容:http://jsfiddle.net/4QF4C/14/

为什么动画中红色方 block 会躲在黑线后面,播放完后又显示出来?我该如何解决这个问题?

HTML:

<div class="container">
    <div class="content">  
        <div class="box-static">
            This is a static box that isn't effected by JQuery.
            <div class="dot"></div>
        </div>
        <div class="box">
            This is just some text.
            <div class="dot"></div>
        </div>
        <a href="#">Click Me!</a>
    </div>
</div>

CSS:

.container {
    width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.content {
    width: 550px;
    float: right;
    border-left: 5px solid black;
    position: relative;
    height: 250px;
}

.box-static {
    width: 500px;
    position: relative;
    padding: 12px; 
    margin: 10px 0 0 17px;
    background-color: lightgrey;
    border: 1px solid black;
}

.dot {
    display: block;
    position: absolute;
    width: 16px;
    height: 16px;
    background-color: red;
    top: 50%;
    left: -28px;
    margin-top: -8px;
}

.dot:after {
    content: "";
    display: block;
    position: absolute;
    width: 8px;
    height: 8px;
    background-color: white;
    top: 4px;
    left: 4px;
}

.box {
    width: 500px;
    position: relative;
    padding: 12px; 
    margin: 10px 0 0 17px;
    background-color: lightgrey;
    border: 1px solid black;
    display: none;
}

JQuery:

$('a').click(function() {
    $(".box").hide().show("blind");
    $("a").hide();
});

请帮忙!

最佳答案

我认为这可以满足您的需求:http://jsfiddle.net/4QF4C/32/

基本上我所做的就是更改以下内容:

.box {
    left: -11px; // Added
    margin: 10px 0 0 28px; // Changed the margin-left portion to add 11px
    overflow: visible; // Added this; not sure if it's necessary
}

这使得 .box 展开以包含 .dot,并位于黑线之上。

关于javascript - 在动画期间盲目隐藏div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20913414/

相关文章:

Javascript数组变成对象结构

css - 必填字段指示器在 IE7 和 IE6 中不起作用

javascript - Ajax 不会在 jQuery 中悬停时更新

javascript - 如何使用按钮从 Fabric.js Canvas 中删除图像

javascript - 迭代完成后使用 Promise

css - 如何更改 IE 中输入字段中文本光标的颜色?

jquery - 在悬停时启用更改图像,然后根据处于事件状态的类禁用 jquery

jquery-ui - jQuery UI 自动完成选择

jquery - Ruby on Rails - jQuery UI Touch Punch

javascript - 如何点击播放歌曲?