父选择器? [英] parent selector?

查看:64
本文介绍了父选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了标记离开我网站的链接,我最近将此规则添加到我的

样式表中。


A [href] [class =" offsite"]:在{content:" \2197" }

这个角色是一个东北方向的箭头,因为这似乎是

相当常见的符号。我想避免使用图像,

,这个内容规则很有效!


我的问题是我的一些非现场链接是图形。我不希望

一条箭挂在我的按钮链接上。是否可以以某种方式禁用此

规则,或者如果锚点包含

图像,则将内容更改回"我知道有一个子选择器A> IMG但是它选择了

图像而不是锚点。似乎我需要一个父选择器,并且有

没有A< IMG等价物。


我错过了一些明显的东西吗?

谢谢,

Tim


-

Tim& Alethea
www.ChristTrek.org

In order to mark links leaving my site, I recently added this rule to my
stylesheet.

A[href][class="offsite"]:after { content: "\2197" }
The character is a northeast-pointing arrow, since that seems to be
fairly common notation for this. I wanted to avoid using an image,
though, and this content rule works great!

My problem is that some of my offsite links are graphics. I don''t want
an arrow hanging off my button links. Is it possible to disable this
rule somehow, or change the content back to "", if the anchor contains
an image? I know there is a child selector A>IMG but that selects the
image not the anchor. It seems I need a parent selector, and there is
no A<IMG equivalent.

Am I missing something obvious?

Thanks,
Tim

--
Tim & Alethea
www.ChristTrek.org

推荐答案

2004年10月12日星期二09:43:39 -0500,Tim& Alethea Larson

< th ******** @ ll.net>写道:
On Tue, 12 Oct 2004 09:43:39 -0500, Tim & Alethea Larson
<th********@ll.net> wrote:
为了标记离开我网站的链接,我最近将这条规则添加到我的
样式表中。

A [href] [class =" offsite"]:在{content:" \2197" }

这个角色是一个东北方向的箭头,因为这似乎是相当普遍的符号。我想避免使用图像,
,这个内容规则很有效!

我的问题是我的一些异地链接是图形。我不想要一个悬挂在我的按钮链接上的箭头。是否可以以某种方式禁用此
规则,或者如果锚包含
图像,则将内容更改回"?我知道有一个子选择器A> IMG但是选择了
图像而不是锚点。看来我需要一个父选择器,并且没有A< IMG等价物。

我错过了一些明显的东西吗?
In order to mark links leaving my site, I recently added this rule to my
stylesheet.

A[href][class="offsite"]:after { content: "\2197" }
The character is a northeast-pointing arrow, since that seems to be
fairly common notation for this. I wanted to avoid using an image,
though, and this content rule works great!

My problem is that some of my offsite links are graphics. I don''t want
an arrow hanging off my button links. Is it possible to disable this
rule somehow, or change the content back to "", if the anchor contains
an image? I know there is a child selector A>IMG but that selects the
image not the anchor. It seems I need a parent selector, and there is
no A<IMG equivalent.

Am I missing something obvious?




假设所有img锚点都在页面的一个部分中,请将它们包含在带有id的div中。然后使用该id作为父级。



Assuming all the img anchors are in one section of the page, enclose them
in a div with an id. Then use that id as the parent.


Tim& Alethea Larson< th ******** @ ll.net>写道:
Tim & Alethea Larson <th********@ll.net> wrote:
为了标记离开我网站的链接,我最近将这条规则添加到我的
样式表中。

A [href] [class =" offsite"]:在{content:" \2197"这个角色是一个东北方向的箭头,因为这似乎是相当普遍的符号。我想避免使用图像,
,这个内容规则非常有用!


它没有,你使用的字形在我的系统上不存在。

我的问题是我的一些非现场链接是图形。我不想要一个悬挂在我的按钮链接上的箭头。是否可以以某种方式禁用此
规则,或者如果锚包含
图像,则将内容更改回"?我知道有一个子选择器A> IMG但是选择了
图像而不是锚点。看来我需要一个父选择器,并且没有A< IMG等价物。

我错过了一些明显的东西吗?
In order to mark links leaving my site, I recently added this rule to my
stylesheet.

A[href][class="offsite"]:after { content: "\2197" }

The character is a northeast-pointing arrow, since that seems to be
fairly common notation for this. I wanted to avoid using an image,
though, and this content rule works great!
It doesn''t, the glyph you are using is not present on my system.
My problem is that some of my offsite links are graphics. I don''t want
an arrow hanging off my button links. Is it possible to disable this
rule somehow, or change the content back to "", if the anchor contains
an image? I know there is a child selector A>IMG but that selects the
image not the anchor. It seems I need a parent selector, and there is
no A<IMG equivalent.

Am I missing something obvious?




a.offsite:在{content:" somethingappropriate"}

< a href =" http:// localhost /" class =" offsite"> foobar< / a>

< a href =" http:// localhost /">< img src =" foobar" alt =" foobar">< / a>

< a href =" index.htm"> foobar< / a>


-

Spartanicus



a.offsite:after{content:"somethingappropriate"}

<a href="http://localhost/" class="offsite">foobar</a>
<a href="http://localhost/"><img src="foobar" alt="foobar"></a>
<a href="index.htm">foobar</a>

--
Spartanicus


Tim& Alethea Larson写道:
Tim & Alethea Larson wrote:
为了标记离开我网站的链接,我最近将这条规则添加到我的样式表中。

A [href] [class =" ; offsite"]:在{content:" \2197" }


你也可以使用


A.offsite [href]:{}


你可能会发现更容易阅读。更好的是,


A.offsite:在{}


之后,假设你没有< A>用作目标锚点的元素。我使用id为

,所以没有< A>我的页面中没有href属性的元素。

缺点是Netscape 4-不会识别目标的id。但是

它的使用率对我来说足够低,我不会担心目标失败。 :-)

角色是一个东北方向的箭头,因为这似乎是相当常见的符号。我想避免使用图像,
,这个内容规则非常有用!


在Opera和Moz上,可能还有Safari和其他人。但你确实知道它在MSIE上失败了
,对吗?

我的问题是我的一些异地链接是图形。我不希望箭头悬挂在我的按钮链接上。如果锚
包含图像,是否可以以某种方式禁用此规则,或将内容更改回"?


Spartanicus为您提供了最简单的解决方案:从带有图片的链接中删除offsite类&b
。如果你想把这个课程保留为其他

的原因,你也可以使用多个班级:

< a href =" samesite.html">这个链接有之后没有图标< / a>


< a href =" http://www.example.com/bar" class =" offsite">这个链接有一个

漂亮的图标,表明它离开现场< / a>


< a href =" ; HTTP://www.example.com/foo" class =" offsite withImg">< img

src =" foobar.png" alt ="此链接*不*后面有一个图标">< / a>

A.offsite:在{content:" arrow"}

A.offsite.withImg:在{content:""}

之后我知道有一个子选择器A> IMG但选择的图像不是<锚。看来我需要一个父选择器,并且没有A< IMG
等价物。
In order to mark links leaving my site, I recently added this rule to
my stylesheet.

A[href][class="offsite"]:after { content: "\2197" }
You can also use

A.offsite[href]:after {}

which you might find easier to read. Better still,

A.offsite:after {}

assuming you have no <A> elements used as target anchors. I use id for
that, so there are no <A> elements in my page without an href attribute.
The drawback is that Netscape 4- will not recognize id for targets. But
its usage is low enough for me that I don''t fret about target failures. :-)
The character is a northeast-pointing arrow, since that seems to be
fairly common notation for this. I wanted to avoid using an image,
though, and this content rule works great!
On Opera and Moz, possibly Safari and others, sure. But you do know it
fails on MSIE, right?
My problem is that some of my offsite links are graphics. I don''t
want an arrow hanging off my button links. Is it possible to disable
this rule somehow, or change the content back to "", if the anchor
contains an image?
Spartanicus gave you the easiest solution: remove the class "offsite"
from links with images. If you want to keep that class for other
reasons, you can also use multiple classes:
<a href="samesite.html">this link has no icon after it</a>

<a href="http://www.example.com/bar" class="offsite">this link has a
nifty icon to show that it goes offsite</a>

<a href="http://www.example.com/foo" class="offsite withImg"><img
src="foobar.png" alt="this link does *not* have an icon after it"></a>
A.offsite:after {content:"arrow"}

A.offsite.withImg:after {content: ""}

I know there is a child selector A>IMG but that selects the image not
the anchor. It seems I need a parent selector, and there is no A<IMG
equivalent.




正确,css 2中没有父选择器。 />

-

Brian(删除无效给我发电子邮件)
http://www.tsmchughs.com/


这篇关于父选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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