- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个网站,导航按钮像往常一样有 3 种状态,初始空闲状态、悬停状态和点击状态以及显示您所在页面的状态。
我想我应该为 :hover 和 :active 状态添加一些不错的转换,虽然 :hover 工作得很好,但我似乎无法让 :active 按我想要的方式工作。
如果您看一下这个 fiddle ,您将更清楚地了解我要实现的目标: http://jsfiddle.net/number8pie/3BvhM/2/
正如您在 :hover 上看到的那样,有一个我认为看起来相当不错的不透明度过渡,但是当您单击链接时,我希望将 about_us.png 和 about_us_hover.png 设置为不透明度 0(使用过渡)和 about_us_active .png 保持可见。
这是 HTML:
<ul class="right"> <!-- no closing tag on <li> so that the whitespace between elements is removed-->
<li id="about-us">
<a class="nav-link" href="#">
<div class="icon-cont">
<img class="top" src="http://s28.postimg.org/7u46xdbjd/about_us.png">
<img class="middle" src="http://s28.postimg.org/mel9s76i1/about_us_hover.png">
<img class="bottom" src="http://s28.postimg.org/bt1eg706h/about_us_active.png">
</div>
<span class="nav-text">about us</span>
</a>
<li id="products">
<a class="nav-link" href="#"><span class="nav-text">products</span></a>
<li id="the-team">
<a class="nav-link" href="#"><span class="nav-text">the team</span></a>
<li id="environment">
<a class="nav-link" href="#"><span class="nav-text">environment</span></a>
<li id="contact">
<a class="nav-link" href="#"><span class="nav-text">contact</span></a>
</ul>
还有 CSS:
ul li {
height: 56px;
width: 56px;
margin: 0;
font-family: 'RobotoLight';
font-size: 21px;
display: inline-block;
text-transform: uppercase;
}
.icon-cont {
position: relative;
height: 56px;
width: 56px;
margin: 0;
}
.icon-cont img {
position: absolute;
left: 0;
-webkit-transition: opacity 0.4s ease-in-out;
-moz-transition: opacity 0.4s ease-in-out;
-o-transition: opacity 0.4s ease-in-out;
transition: opacity 0.4s ease-in-out;
}
.icon-cont img.top {
z-index: 30;
}
.icon-cont img.middle {
z-index: 20;
}
.icon-cont img.bottom {
z-index: 10;
}
.icon-cont img.top:hover {
opacity: 0;
}
.icon-cont img.top:active {
opacity: 0;
}
.icon-cont img.middle:active {
opacity: 0;
}
.nav-text {
font-size: 0;
position: absolute;
left: -1000px;
}
在此先感谢您的帮助和/或建议。
最佳答案
您可以使用一些 CSS 技巧来完成大部分工作 - 即依靠兄弟隐藏输入的 :checked
状态来控制 label
的外观。
要根据当前页面设置状态,您可能需要使用一些 JS 来识别页面,然后将合适的类应用于相关元素。
这将适用于开/关点击状态。如果您想要按下(鼠标按下)状态,您应该在代码中使用 button
元素而不是 anchor a
标签来应用 :active
到。
(alternate demo using a button and :active
)
HTML
<input type='checkbox' id='menuItem' />
<label for='menuItem'>i</label>
CSS
input {
display:none;
}
label {
display:inline-block;
height:50px;
width:50px;
line-height:50px;
color:white;
font-size:1.5em;
font-style:italic;
font-family:arial;
background:lightgreen;
text-align:center;
position:relative;
transition:all 200ms ease-in;
}
label:after {
height:30px;
width:30px;
content:'';
border:4px solid white;
border-radius:100%;
display:inline-block;
position:absolute;
left:6px;
top:6px;
opacity:0;
transition:all 200ms ease-in;
}
label:hover:after {
opacity:1;
}
input:checked+label {
background:none;
color:lightgreen;
}
input:checked+label:after {
border-color:lightgreen;
}
关于html - 3 图像过渡不透明度点击问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24805756/
我正在制作一个应用程序,我需要使用 ffmpeg 将两个视频文件叠加在另一个之上。 .我尝试了各种命令,但它所做的只是合并视频。 最佳答案 基本方法是 ffmpeg -i in1 -i in2 -fi
我将 Qt3D 与 offscreen renderer 结合使用并修改框架图以包含背景图像,例如 here . 不幸的是,使用 QPhongAlphaMaterial 为绘制在背景图像上的对象添加透
我正在开发的这个组件有视觉问题。它是带有 2 个 JTextField 和 2 个 JLabel 的 JPanel。我不能做坚实的背景。我尝试了几种不透明/背景颜色组合但没有成功。 我不允许附加图像,
我正在使用 Gnuplot 成功绘制一些时间序列数据。然而,该系列相当密集(大约 5 英寸空间中有 10,000 个样本),当我绘制多个系列时,很难看到绘制在顶部的系列下方。 有什么方法可以使线条具有
我正在尝试设置一个自定义拖动图标以在 NSTableView 中使用。一切似乎都正常,但由于我对 Quartz 缺乏经验,我遇到了问题。 - (NSImage *)dragImageForRowsWi
是否可以制作例如 20% 透明的 TMemo 或其他 vcl 组件?像 TButton 或 TEdit 吗? 在谷歌搜索解决方案时,我发现了这个: From Here ,然后我想,如果我在窗体上绘制图
我目前正在学习如何使用 Scenekit,并且遇到了透明对象的问题。我写了一个着色器来增加正面看脸时的透明度,当我选择白色背景时,一切都按预期工作...... transparency with wh
我对 openGL 中的 alpha 混合有疑问... 我尝试了一些绘制透明对象的方法...通过在绘制透明面之前禁用 GL_DEPTH_TEST 并在绘制透明面后再次重新启用 GL_DEPTH_TES
我正试图让我的背景 webView 像那样透明: webView.setBackgroundColor(0x00000000); 但它不起作用,如果我添加这一行,一切都是透明的(我看不到我的 html
我目前正在创建一个应用程序并且出现了这个问题,我想让 TabLayout 透明。当我使用 RelativeLayout TabLayout 覆盖内容时,当我使用 LinearLayout TabLay
我有一个 UINavigationItem(不是 UINavigationBar),我想使其透明或不透明。这是在我建立从导航 Controller 到我的 UIViewController 子类的关系
是否可以让您的 android Activity 以透明模式在当前正在运行的 Activity 之上运行,以便您可以通过它看到它下面的 Activity ?如果可能,您可以设置不同级别的透明度吗? 最
我正在使用 noUiSlider 范围 slider 。这是 jsfiddle: https://jsfiddle.net/oun5p1xz/ behaviourSlider = document.g
有没有办法改变控制台的不透明度使其半透明? 还有办法将控制台的背景颜色更改为自定义颜色吗? 最佳答案 快速谷歌显示 this site其中包含用于具有透明窗口的控制台应用程序的代码。 本质上,您必须获
主.xml: 这是我的 main.xml,我试图使按钮最透明,但我仍然想看到它们,但我不知道要添加什么以及在哪里添加,请用低不透明度更正我的 xml在按钮
如何将实际内容 Pane 的背景设置为不透明,我添加到其中的面板我已经设置为不透明,但即使我这样做,选项卡 Pane 的主要区域仍显示为蓝色 JTabbedPane tabbedPane = new
是否可以继承颜色但覆盖不透明度值?以下是伪 CSS 中的示例: .color-class { background-color: rgba(255, 0, 0, 0); } .lighten
我正在尝试让我的导航栏变得 100% 透明,以便 UINavigationButtonItems 只可见并且背景(通常为白色)应该显示背景图像。 我试过了 HomeNavigationControll
RGBA 非常有趣,-webkit-gradient、-moz-gradient 和呃... progid:DXImageTransform.Microsoft.gradient 也是如此...是的。
我一直在尝试使用 AppBarLayout,但找不到使它的背景透明的方法。 我的意思是: 这是我的 XML: 如您所见,我使用的是颜色 #8000
我是一名优秀的程序员,十分优秀!