To anonymous element add pseudo element and cursor style and event listeners

前端 未结 1 1550
忘掉有多难
忘掉有多难 2021-01-22 09:49

I have this anonymous element in the toolbarbutton xul element. It\'s a xul:image. I want to give it a pseudo element (:before, :aft

1条回答
  •  情书的邮戳
    2021-01-22 10:08

    It doesn't seem like these nested, anonymous xul:image nodes support (::before) pseudo-elements at all. Or maybe it is because the toolbarbutton binding is display="xul:button"... Somewhere deep inside the layout engine the parent element outright refused to adopt the generated ::before pseudo-element, my debugger says. Remember that XUL != HTML.

    However, you can bind and/or rebind stuff to a new binding.

    I used this CSS to re-bind and style the sync button (analog to your example from the question comments, but not meant to be a pixel-perfect reproduction):

    #PanelUI-fxa-status {
      -moz-binding: url(toolbarbutton.xml#toolbarbutton);
    }
    #PanelUI-fxa-status .toolbarbutton-badge {
      list-style-image: url(chrome://browser/skin/places/query.png);
      transform: translate(8px,8px) scale(0.7);
      border: 1px solid red;
    }
    

    And the new binding, based on the default binding:

    
    
    
    
    
      
        
          
        
    
        
          
          
            
            
          
          
          
        
      
    
    

    You could either set the badge with CSS, as I did, or using (i.e. the src=badge inheritance in the binding).

    Regarding the addEventListener/cursor stuff: It is not quite clear here what exactly you are asking for?

    You can use all the usual methods with the toolbar button (addEventListener, command=/oncommand=, ...), but not with child elements of it.

    You can use cursor: styles with the toolbarbutton, but not with child elements of it.

    Both are due to display="xul:button" in the binding. If you don't want that, you'll need to modify the binding not to use a display= and fix any stuff that breaks.

    0 讨论(0)
提交回复
热议问题