How to workaround: IE6 does not support CSS “attribute” selectors

前端 未结 7 977
青春惊慌失措
青春惊慌失措 2020-12-18 22:21

One of the projects which I am working uses CSS \"attribute\" selector [att]

CSS Selectors

which is not supported by ie6: Support for CSS selectors in IE6 (

7条回答
  •  一向
    一向 (楼主)
    2020-12-18 23:24

    You can use Internet Explorer CSS expressions combined with the safe underscore ("_", IE6 and earlier) CSS hack:

    /* Adds dotted bottom border to `` with a `title` attribute. */
    abbr {
            _border-bottom: expression(this.title ? '1px dotted' : 'none');
    }
    
    abbr[title] {
            border-bottom: 1px dotted;
    }
    

    I do understand, that you did ask for "valid" CSS, but if the CSS hack above freaks you out, please read about Safe CSS Hacks.

    The above could be changed to:

    .ie6 abbr {
            _border-bottom: expression(this.title ? '1px dotted' : 'none');
    }
    
    abbr[title] {
            border-bottom: 1px dotted;
    }
    

    That is if your HTML began as:

    
    
    
    
    

提交回复
热议问题