HTML/CSS - 让 child 留在 parent 里面?

标签 html css

此站点的标题在悬停时展开,显示隐藏的 span。 但是,本应顺利显示的图像在标题之外有点滞后。 不好解释,随便看看:http://jsfiddle.net/56t9r/

.header {
    background:#FFF;
    border-bottom:1px solid gray;
    box-shadow:0 0 10px;
    height:70px;
    position:fixed;
    top:0px;
    width:100%;
    z-index:2;
    transition: height 1s ease;
}
.header:hover {
    height: 120px;
    transition: height 1s ease;
}
.kielet {
    top:0px;
    width:100%;
    background: rgb(255, 255, 255);
    /* Old browsers */
    background: -moz-linear-gradient(top, rgba(255, 255, 255, 1) 0%, rgba(229, 229, 229, 1) 100%);
    /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(255, 255, 255, 1)), color-stop(100%, rgba(229, 229, 229, 1)));
    /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, rgba(255, 255, 255, 1) 0%, rgba(229, 229, 229, 1) 100%);
    /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, rgba(255, 255, 255, 1) 0%, rgba(229, 229, 229, 1) 100%);
    /* Opera 11.10+ */
    background: -ms-linear-gradient(top, rgba(255, 255, 255, 1) 0%, rgba(229, 229, 229, 1) 100%);
    /* IE10+ */
    background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 0%, rgba(229, 229, 229, 1) 100%);
    /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#e5e5e5', GradientType=0);
    /* IE6-9 */
    padding:0px;
    height: 0px;
    box-shadow: 0 4px 2px -2px gray;
    color: red;
    transition: height 1s ease;
}
.kielet nav {
    text-align: center;
    height: 0px;
    position: static;
    transition: height 1s ease;
}
.header:hover > .kielet nav {
    height:50px;
    position: static;
}
.kielet a {
    display: inline;
    left: 0px;
}

最佳答案

Fiddle

.header {
  overflow: hidden;
  ...
}

.header :hover **

.header .kielet nav {
    height: 50px;
    position: static;
}

关于HTML/CSS - 让 child 留在 parent 里面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20242452/

相关文章:

javascript - 是否可以在 Javascript 中添加过渡(如 CSS)?

python - python flask 的 html 选项卡拆分

html - 如何禁用 HTML 电子邮件以使用深色模式进行调整?

javascript - 我的网页显示“而不是”

javascript - 使用 Javascript 显示隐藏的 CSS 类 - 表单元素

javascript - 有没有办法使过渡属性适用于 javascript 选定项?

javascript - SIMPLE 切换图片查询

javascript - GoogleMaps API 仅在开发工具打开时工作

php - 如何在此代码中添加大小限制?

javascript - 我想要一个拼写检查器插件到 html 可编辑 div 中吗?