什么是替代的子选择器? [英] What is the replacement for the child selector?

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

问题描述

由于IE6不支援子选择器(请参阅 http://kimblim.dk/csstest/#ex1 ),处理此浏览器时有什么替代方法?

Since IE6 does not support the child selector (see http://kimblim.dk/csstest/#ex1), what is the alternative when dealing with this browser?

我不想修改标记,我更喜欢CSS-只有解决方案...

I do not want to modify the markup, and I'd much much prefer a CSS-only solution...

是的,它是我想指向的直接孩子。

And yes, it is the direct child that I wish to target.

谢谢!

推荐答案

我遇到了一个黑客的问题: http://meyerweb.com/eric/thoughts/2005/05/31/universal-child-replacement/
使用 star html a>'hack for IE(6及以下)结合此允许我选择直接子。假设我们要对E的直接子节点F应用一个10px的padding-top:

I've come across something of a hack: http://meyerweb.com/eric/thoughts/2005/05/31/universal-child-replacement/ Using the 'star html' hack for IE (6 and below) in combination with this allows me to select the direct child. Let's say we want to apply a padding-top of 10px to the direct child, F, of E:

* html body E F
{
    /* apply style here for IE 6 */
    padding-top: 10px;
    /* This applies the style to every F inside of E */
}
* html body E * F
{
    /* undo style here */
    padding-top: 0px;
    /* This will undo the style set above for every F that has something in between itself and E, that is, every F besides the direct children of E */
}

我真的很感谢你的回答,但我讨厌接受我自己的答案,这是我最终解决的解决方案。谢谢你们!

I do appreciate your responses so far but as much as I hate to accept my own answer, this was the solution I eventually settled on. Thanks guys!

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

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