[英]Border color change on hover
I have been trying to create a border-color
change hover effect with CSS and something seems to not be working properly. 我一直在尝试使用CSS创建border-color
更改悬停效果,并且某些功能似乎无法正常工作。 Here is my code: 这是我的代码:
Markup: 标记:
<ul>
<li class="hover">
<img src="img/content/lighter.png" alt="lighter"/>
<p>Discusing Strategy</p>
</li>
<li class="triangle"></li>
<li class="hover">
<img src="img/content/wrench.png" alt="wrench"/>
<p>Beginig <br/> Designs & Development</p>
</li>
<li class="triangle"></li>
<li>
<img src="img/content/car.png" alt="car"/>
<p>Delivering Product</p>
</li>
</ul>
CSS: CSS:
div#bpath ul li.triangle {
width: 0;
height: 0;
border-top: 95px solid #d0dde5;
border-left: 20px solid #c1c1c1;
border-bottom: 95px solid #d0dde5;
}
div#bpath ul li.hover:hover li.triangle {
border-left-color: #5f9999;
}
What am I doing wrong here? 我在这里做错了什么? I used the same technique to change the color of the p
element and that worked. 我使用相同的技术来更改p
元素的颜色,并且该方法可行。 Why dosen't the border color change work? 为什么边框颜色更改不起作用?
Your selector: 您的选择器:
div#bpath ul li:hover li.triangle
is trying to match a li
element of class 'triangle' within an li
. 尝试匹配一个li
的内类“三角形”的元件li
。 As you don't appear to have a nested list (therefore no li
elements within other li
elements) this doesn't seem able to work. 当你这样做似乎没有一个嵌套列表(因此没有li
等内的元素li
元素)这似乎并不能工作。
If you remove the latter li
( li.triangle
) to give (all, or one, of) the following: 如果删除后一个li
( li.triangle
)以给出(全部或一个)以下内容:
div#bpath ul li:hover,
#bpath ul:hover li.triangle:hover,
#bpath ul:hover li.triangle,
#bpath ul li.triangle:hover {
border-left-color: #5f9999;
}
this might work. 这可能有效。 Assuming your posted-HTML is correct. 假设您发布的HTML是正确的。
If you want all triangle li's to be changed use this: 如果要更改所有三角形li,请使用以下命令:
div#bpath ul:hover li.triangle{
border-left-color: #5f9999;
}
If you want just the next triangle element it's more tricky but you can try this: 如果只需要下一个三角形元素,则比较棘手,但是可以尝试以下操作:
div#bpath ul li:hover + li.triangle {
clear:both;
}
I think this doesn't work on ie. 我认为这不起作用。 If you want it to work on IE i would go for jquery. 如果你希望它在IE浏览器我会去的jQuery。
you should use this way, 你应该用这种方式
div#bpath ul li.triangle:hover {
border-left-color: #5f9999;
}
you can use this fiddle, which changes the triangles color and adapt it to clarify your question. 您可以使用此小提琴来更改三角形的颜色并对其进行修改以阐明您的问题。 http://jsfiddle.net/j7YSu/1/ http://jsfiddle.net/j7YSu/1/
(or just accept it as the right answer :)) (或只是接受它作为正确的答案:))
i had some issues with your code, but maybe this fiddle will help: http://jsfiddle.net/j7YSu/3/ 我的代码有问题,但也许这个小提琴会有所帮助: http : //jsfiddle.net/j7YSu/3/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.