jquery - 我想将 div 扩展到其隐藏的子 div 的左侧?

标签 jquery html css

我想制作隐藏有子 div 的侧边栏 div。当翻转父 div 时,它将展开并且子 div 暴露,并且在推出 div 时恢复到其原始大小折叠。 我想要我的侧边栏类似于这个。 http://www.hosting.com/它的联系人侧边栏,我真的很想要这样。

CSS

#Sidebar {
    width: 40px;
    height: 40px;
    margin-right: 0px;
    top: 300px;
    position: fixed;
    right: 0px;
    background-image: url(chat.png);
    background-repeat: no-repeat;
    background-size: cover;
    color: #FFF;
    -webkit-transition: all 1s ease 0s;
    -moz-transition: all 1s ease 0s;
    -ms-transition: all 1s ease 0s;
    -o-transition: all 1s ease 0s;
    transition: all 1s ease 0s;
    background-color: #F90;
    }
#Sidebar:hover {
    height: 50px;
    width: 100px;
}
.divchild {
    height: 25px;
    width: 25px;
    background-color: #0F3;
    top: 5px;
    right: 0px;
    margin: auto;
    position: relative;
}

HTML

<a href="#">
<div class="Sidbaredges" id="Sidebar">
 <div class="divchild"></div>
 </div>
</a>

最佳答案

试试这个

http://jsfiddle.net/mqzMx/

CSS

#Sidebar {
    width: 40px;
    height: 40px;
    margin-right: 0px;
    top: 300px;
    position: fixed;
    right: 0px;
    background-image: url(chat.png);
    background-repeat: no-repeat;
    background-size: cover;
    color: #FFF;
    -webkit-transition: all 1s ease 0s;
    -moz-transition: all 1s ease 0s;
    -ms-transition: all 1s ease 0s;
    -o-transition: all 1s ease 0s;
    transition: all 1s ease 0s;
    background-color: #F90;


}
#Sidebar:hover {
    height: 50px;
    width: 100px;
    float:left;
}
.divchild {
    height: 25px;
    width: 25px;
    background-color: #0F3;
    top: 7px;
    left: 10px;
    margin: auto;
    position: relative;
    text-align:left;
    display:inline-block;
}

关于jquery - 我想将 div 扩展到其隐藏的子 div 的左侧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17630556/

相关文章:

javascript - JQuery JSON 调用 PHP WebService 总是运行 "Error"回调

html - MVC4 移动 Web 应用进入应用商店

javascript - div类更改时更改背景颜色?

javascript - 使用 Kendo Grid 如何删除列边框?

JavaScript/jQuery : How to make sure cross-domain click tracking event succeeds before the user leaves the page?

javascript - 在 $.each 函数中传递对象

javascript - 为类中的每个元素添加特定的悬停

html - 使用css3动画的 float 按钮

javascript - 如何只打开新标签页 1 次?

javascript - 菜单在不应该的时候中断