更改外DIV的财产,而徘徊在内部&LT; A&GT;元件 [英] Changing the property of outer DIV while hovering over inner <a> Element
问题描述
我试图使纯CSS方式按钮(我试图避免的JavaScript尽可能)
我有以下的code
I am trying to make a button in a purely CSS way (I am trying to avoid javascript as much as possible) I have the following code
CSS:
.Button a{
text-align:center;
vertical-align:middle;
background-color:transparent;
Height:100%;
color:white;
text-decoration:none;
}
.Button a:hover{
background-color:brown;
cursor:default;
}
.Button a:active{
background-color:gray;
}
现在,我的问题是,我想改变外部元素的背景颜色(具有类按钮)。以上code,而改变的封闭元素的背景颜色。任何想法如何,我可以得到这个(不使用JavaScript)?
Now, my problem is that I wish to change the background color of the outer element (the one with class as 'Button'). The above code changes the background color of the element rather the the enclosing . Any ideas how I can get this (without using javascript)?
推荐答案
我回答我的问题,希望,如果他们有其他的,在这个线程谁可能绊倒以后,可以享受同样的问题(所以他们需要像我那样抓取网页今天:-P)。
I am answering my own question, in the hope that the others, who might stumble upon this thread later on, can benefit if they have the same problem (so that they need to crawl the web as much as I did today :-P).
作为,难以捉摸的说,这是不会可以选择通过CSS选择器父元素。
As, Elusive said, it is NOT possible to select a parent element through CSS-selectors.
而code以下为我工作:
And the code below worked for me:
a.Button {
text-align:center;
vertical-align:middle;
background-color:transparent;
display:block;
Height:100%;
min-width:100px;
color:white;
padding:3px 3px 3px 3px;
text-decoration:none;
}
a.Button:hover{
background-color:brown;
cursor:default;
}
a.Button:active{
background-color:gray;
}
我做的&lt;一>元素显示风格'块'。而我能够实现我一直在寻找的效果。
I made the < a> element display style 'block'. And I was able to achieve the effect I was looking for.
这篇关于更改外DIV的财产,而徘徊在内部&LT; A&GT;元件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!