似乎不可能 [英] Doesn't seem possible

查看:69
本文介绍了似乎不可能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎不可能。但是下面的内容似乎也会违反css背后的一般概念吗?


你有一个DIV,说与课程相关,''topdiv'' 。


其中你有一个锚(以及它包含的任何东西),

与班级相关,''a''。


其他地方,''topdiv'',有一个span或元素(包含

无论如何),与类相关联,''b''。


你能看到伪选择器:悬停为''a'',并以某种方式修改

演示'b''?


..topdiv.a A:悬停.b?


锚元素成为b的样式更改触发器,其他

话。这似乎不可能。然而''a''和'b''都在
''topdiv''的范围内,但在彼此的范围之外。

It doesn''t seem possible. But would the following also seem a
violation of the general notions behind css?

You have a DIV, say asociated with class, ''topdiv''.

Inside of that you have an anchor (and whatever it contains),
associated with class, ''a''.

Somewhere else in, ''topdiv'', there is a span or element (containing
whatever), associated with class, ''b''.

Can you read the pseudo selector :hover for ''a'', and somehow modify
presentation for ''b''?

..topdiv.a A:hover .b ?

The anchor element becomes a trigger for a style change to b, in other
words. It doesn''t seem possible. Yet both ''a'' and ''b'' are in scope in
''topdiv'', but outside each other''s scope.

推荐答案

Mark Johnson< 10 ******* @ compuserve.com>写道:
Mark Johnson <10*******@compuserve.com> wrote:
这似乎不可能。但是下面的内容是否也会违反css背后的一般概念?

你有一个DIV,比如与班级相关,''topdiv''。

>其中你有一个锚(以及它包含的任何东西),
与班级相关,''a''。

其他地方,''topdiv'',有一个span或元素(包含
无论如何),与类相关联,''b''。

你能读取伪选择器:悬停为''a'',并以某种方式修改

.topdiv.a A:悬停.b?


我以为你说锚是class =" a"?以上选择

作为儿童的锚。

< div>

< div class =" a"> < a href =""> foo< / a>< / div>

< div class =" b">< / div>

< / div>


但是如果您的原始描述准确无误,那么我们将会看到

at:

< div>

< a class =" a" href =""> foo< / a>

< div class =" b">< / div>

< / div>

锚元素成为b的样式更改的触发器,用其他单词表示。这似乎不可能。然而''a''和'b''都在
''topdiv''的范围内,但在彼此的范围之外。
It doesn''t seem possible. But would the following also seem a
violation of the general notions behind css?

You have a DIV, say asociated with class, ''topdiv''.

Inside of that you have an anchor (and whatever it contains),
associated with class, ''a''.

Somewhere else in, ''topdiv'', there is a span or element (containing
whatever), associated with class, ''b''.

Can you read the pseudo selector :hover for ''a'', and somehow modify
presentation for ''b''?

.topdiv.a A:hover .b ?
I thought you said that the anchor was class="a"? The above selects
for anchors that are children of a.
<div>
<div class="a"><a href="">foo</a></div>
<div class="b"></div>
</div>

However if your original description was accurate then we''d be looking
at:
<div>
<a class="a" href="">foo</a>
<div class="b"></div>
</div>
The anchor element becomes a trigger for a style change to b, in other
words. It doesn''t seem possible. Yet both ''a'' and ''b'' are in scope in
''topdiv'', but outside each other''s scope.




听起来像兄弟选择器。


a + b匹配b是兄弟姐妹(同一直接父母)a。


所以你我想要(假设上面的第二个html例子)。

..a:hover + .b {styles}


但是不行。不能在IE中工作,因为IE不支持

兄弟选择器。在Mozilla和Opera中不起作用,因为,当我想到兄弟选择器

和子选择器div:hover之间的区别时,嗯,不是很好。 b {styles}确实有效(在

时尚之后 - 只要鼠标

移动到任何子元素上,div的悬停状态就会丢失)I开始喋喋不休地谈论

继承但不能产生连贯的解释。


无论如何,是的,看起来纯粹的CSS 2是不可能的时间为

JavaScript。


史蒂夫


-

" ;我的理论给你起见,我的异端邪说你们愤怒,

我从不回信,你不喜欢我的领带。 - 医生


Steve Pugh< st *** @ pugh.net> < http://steve.pugh.net/>



Sounds like a sibling selector.

a + b matches b that is a sibling (same direct parent) of a.

So you''d want (assuming the second html example above).
..a:hover + .b {styles}

But doesn''t work. Doesn''t work in IE because IE doesn''t support
sibling selectors. Doesn''t work in Mozilla and Opera because, um, not
sure, when I think about the difference between the sibling selector
and the child selector div:hover .b {styles} which does work (after a
fashion - the hover state for the div is lost as soon as the mouse
moves over any of the child elements) I start muttering rubbish about
inheritence but can''t produce a coherent explantion.

Anyway, yes it looks like it''s impossible with pure CSS 2. Time for
the JavaScript.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don''t like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>


Mark Johnson写道:
Mark Johnson wrote:
它不是似乎有可能。但是下面的内容是否也会违反css背后的一般概念?

你有一个DIV,比如与班级相关,''topdiv''。

>其中你有一个锚(以及它包含的任何东西),
与班级相关,''a''。

其他地方,''topdiv'',有一个span或元素(包含
无论如何),与类相关联,''b''。

你能读取伪选择器:悬停为''a'',并以某种方式修改

.topdiv.a A:悬停.b?

锚元素成为b的样式更改的触发器其他的话。这似乎不可能。然而''a''和'b''都在
''topdiv''的范围内,但在彼此的范围之外。
It doesn''t seem possible. But would the following also seem a
violation of the general notions behind css?

You have a DIV, say asociated with class, ''topdiv''.

Inside of that you have an anchor (and whatever it contains),
associated with class, ''a''.

Somewhere else in, ''topdiv'', there is a span or element (containing
whatever), associated with class, ''b''.

Can you read the pseudo selector :hover for ''a'', and somehow modify
presentation for ''b''?

.topdiv.a A:hover .b ?

The anchor element becomes a trigger for a style change to b, in other
words. It doesn''t seem possible. Yet both ''a'' and ''b'' are in scope in
''topdiv'', but outside each other''s scope.




你可以把< span class =" b">在< a class =" a">,并使用

定位让它看起来像是在其他地方。


.. topdiv aa:link .b {

position:relative;

left:8em;

top:3em;

颜色:红色;

}

..topdiv aa:悬停.b {

位置:相对;

left:8em;

top:3em;

颜色:蓝色;

}


< div class =" topdiv">

< a class =" a"> hover this< span class =" b">并看到此更改

颜色< / span>< / a>

< / div>


未经测试!


-

Els


Sonhos vem。 Sonhos v?o。 Orestoébritfeito。

- Renato Russo -



You can put <span class="b"> inside <a class="a">, and use
positioning to make it look like it''s somewhere else.

..topdiv a.a:link .b{
position:relative;
left:8em;
top:3em;
color:red;
}
..topdiv a.a:hover .b{
position:relative;
left:8em;
top:3em;
color:blue;
}

<div class="topdiv">
<a class="a">hover this<span class="b"> and see this change
colour</span></a>
</div>

Not tested!

--
Els

Sonhos vem. Sonhos v?o. O resto é imperfeito.
- Renato Russo -


Steve Pugh写道:
Steve Pugh wrote:


听起来像兄弟选择器。

a + b匹配b,它是a的兄弟姐妹(同一个直接父母)。


Sounds like a sibling selector.

a + b matches b that is a sibling (same direct parent) of a.




但是+表示''ADADACENT兄弟姐妹'',所以即使这不是一般的

解决方案。这两个元素必须是相邻的,并且修改后的元素必须是第二个。


以下的操作(在Netscape 7.1上),但是使用嵌套元素和

因此限制性更强:


< style type =" text / css">

..topdiv .a:hover .b {background-color:red;}

< / style>





< div class =" topdiv">

< a class =" a" href ="#dummy">这是放置鼠标的位置。

< span class =" b">包含任何< / span>< / a> <的元素br />
< / div>


Chris Beall



But "+" signifies ''ADJACENT sibling'', so even that isn''t a general
solution. The two elements would have to be adjacent and the one to be
modified would have to come second.

The following DOES work (on Netscape 7.1), but uses nested elements and
is therefore considerably more restrictive:

<style type="text/css">
..topdiv .a:hover .b {background-color: red;}
</style>
:
:
<div class="topdiv">
<a class="a" href="#dummy">This is where to put the mouse.
<span class="b">An element containing whatever</span></a>
</div>

Chris Beall


这篇关于似乎不可能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆