- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在努力使我的 CSS 过渡顺利进行,但我遇到了最后一个问题。我承认这很肤浅,但如果可能的话,我想“修复”它。我已经在 Chrome、Firefox 和 IE 中尝试过它,它在所有浏览器中都是如此。
我正在操作的 UL
和 LI
元素是导航工具栏的一部分。工具栏可以在以下网址的左上角看到: http://fretfast.com/templates/clean/sample.php
当您将鼠标悬停在具有可扩展列表的元素之一上时,例如 learn
、teach
或 community
,您将看到它扩展得非常顺利(当然,假设您的浏览器支持 CSS3 转换);然而,当您将鼠标从可扩展列表中移开时,列表顶部的边缘区域会立即消失,这使得所有后续文本向上移动的速度太快。
例如,如果您将鼠标悬停在 learn
上,将显示一个可扩展菜单,其中提供了 lessons
、questions
和 提示
。但是,当您将鼠标移出并且菜单折叠时,第一个选项 (lessons
) 会立即向上推,使其位于按钮正文 (learn
) 的正下方.
这是我用于导航栏的 CSS,但我一直想不通为什么高度过渡只能在一个方向上起作用。
#topNav {
list-style-type: none; height: 25px; padding: 0; margin: 0;
}
#topNav * { font-size: 15px; }
#topNav li {
float: left; position: relative; z-index: 1;
padding: 0; line-height: 23px; background: none; repeat-x 0 0;
padding-top: 2px;
}
#topNav li:hover {
background-color: #C0C0C0; z-index: 2;
padding-top: 0;
border-top: 2px solid #59B4FF;
}
#topNav li a {
display: block; padding: 0 15px; color: #000; text-decoration: none;
}
#topNav li a:hover { color: #222222; }
#topNav li ul {
opacity: 0; position: absolute; left: 0; width: 8em; background: #C0C0C0;
list-style-type: none; padding: 0; margin: 0;
}
#topNav li:hover ul { opacity: 1; }
#topNav li ul li {
float: none; position: static; height: 0; line-height: 0; background: none;
}
#topNav li:hover ul li {
height: 25px; line-height: 25px;
}
#topNav li ul li a { background: #C0C0C0; }
#topNav li ul li a:hover {
text-indent: 0.3em;
background-color: #59B4FF;
}
#topNav li {
transition: background-color 0.2s ease;
-o-transition: background-color 0.2s ease;
-moz-transition: background-color 0.2s ease;
-webkit-transition: background-color 0.2s ease;
}
#topNav li a {
transition: all 0.2s ease;
-o-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
}
#topNav li ul {
transition: all 0.3s ease;
-o-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
}
#topNav li ul li {
transition: height 0.5s ease;
-o-transition: height 0.5s ease;
-moz-transition: height 0.5s ease;
-webkit-transition: height 0.5s ease;
}
#topNav li ul li a {
transition: all 0.3s ease;
-o-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
transition: text-indent 0.1s linear;
-o-transition: text-indent 0.1s linear;
-moz-transition: text-indent 0.1s linear;
-webkit-transition: text-indent 0.1s linear;
}
我也不认为它与#topNav li
中的padding-top
规范有任何关系,因为我今天刚刚添加了它以实现边框高亮效果而且这个问题已经持续了更长的时间。非常感谢任何帮助。
最佳答案
导致这种情况的属性是行高;更具体地说是这个。
#topNav li:hover ul li {
height: 25px;
line-height: 25px;
}
如果您查看转换,它仅在高度上指定。您可以将过渡更改为全部,它似乎显示正常。如果不是,最好的办法可能是在非悬停属性中将行高设置为 25px,而不是在悬停属性中设置行高(即固定)
#topNav li ul li {
transition: all 0.5s ease;
}
如何轻松调试与悬停相关的问题??
在 Chrome 检查器中,选择定义悬停的元素,转到样式选项卡,选择切换元素状态并选中悬停。现在状态设置为永久悬停。只需四处检查和取消检查属性,看看哪里有问题。
关于CSS Transition - UL/LI 标签中的高度问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15097687/
尝试添加动画以替换 fragment 时抛出该异常。根据这个答案,stackoverflow ,过渡框架不能应用于 fragment ,但这篇文章表明你可以 How to use Material T
还有其他一些类似的问题,但都涉及 Android 支持库。我正在使用新的 androidx 库。 将 androidx 生命周期依赖项从 2.2.0-alpha03 更新到 2.2.0-alpha04
这个问题在这里已经有了答案: What is an optional value in Swift? (15 个答案) When two optionals are assigned to an i
Tailwind 提供了多个实用程序来控制哪些 CSS 属性转换,在这些属性中有 transition 和 transition-all。 我去检查了两个类的 CSS 属性,这里它们的顺序相同。 tr
Tailwind 提供了多个实用程序来控制哪些 CSS 属性转换,在这些属性中有 transition 和 transition-all。 我去检查了两个类的 CSS 属性,这里它们的顺序相同。 tr
这是一个由两部分组成的问题: 哪种应用样式优先:CSS 中的 -webkit-transition 规则或 jQuery 中类似的 $.css() 方法? 如果我还在 jQuery 中使用 .css
我想知道为什么在 FireFox 中使用 transition: all 0.5s ease-out; 时我会看到元素上的闪烁效果(截至本文撰写时的最新版本)。很难解释,但请在此处查看实际示例:htt
我对 css3 过渡属性的渲染速度有疑问。 假设我有一些元素: div, span, a {transition: all} div {margin: 2px} span {opacity: .5}
我对 css3 过渡属性的渲染速度有疑问。 假设我有一些元素: div, span, a {transition: all} div {margin: 2px} span {opacity: .5}
我目前正在用 Html 制作我的第一个网站,javascript 作为前端将首先出现。 我正在尝试创建一个折叠侧边栏,当我单击顶部导航右侧的按钮时会出现该侧边栏,但我对过渡效果有疑问,因为它会将所有内
我有一个 Activity ,一次托管一个 fragment ,并在两个 fragment 之间交换。 fragment A 使用按钮启动 fragment B, fragment B 使用按钮或后退
我正在尝试创建一种效果: 光标悬停在一个框上 横杆滑出 随着滑动 Action 缓和,标题出现 光标离开方框 随着栏向后滑动,标题开始消失 横杆完成向后滑动 但是,当光标离开框时,会再次调用延迟,因此
让我提供一些背景信息:我正在构建一个选项卡式应用程序,允许用户查找和查看我们服务器上托管的一些视频。每个选项卡都以不同的方式对视频进行分组,导航栏中有一个分段控件,用户可以使用该控件更精确地对列表进行
原始问题...更新了以下工作代码: 我有一个在 ajax 加载事件期间出现的加载图像。图像通过向 body 元素添加或删除“加载”类来显示/隐藏。目前,加载图像将背景大小设置为从 0% 到 100%
我对 css3 过渡属性的渲染速度有疑问。 假设我有一些元素: div, span, a {transition: all} div {margin: 2px} span {opacity: .5}
当我继续学习前端开发和练习 Sass 优化我的 CSS 代码时,我又遇到了另一种情况。 在互联网上进行研究和教程后,我在 Sass 中设置了名为“transition”的全局混合。代码如下所示: @m
关于 Chrome 和 css 转换的问题太多了,我不确定以前是否有人问过这个问题。 我的情况是这样的:我的布局基本上是左右分页。右侧的一框内容需要显示在左侧的内容之上(这个我没有发言权,桌面和移动之
我在两个 Activity 之间的共享元素中使用了自定义 Transition。 我的转换不起作用,因为 TransitionValues 参数在 captureStartValues 和 这两种方法
我在 google Chrome 和 Safari 上运行我的应用程序,两者都兼容 webkit。我正在使用 -webkit-transition 构建一个滚动的 div。 当我将文档类型指定为 HT
以下代码在 chrome 中产生了预期的结果,即;直接向所有元素添加过渡延迟。 $('.front-nav .sub-menu').each(function() { var transiti
我是一名优秀的程序员,十分优秀!