Content property for parameter tag not working

Edited to make it non-duplicate:

  Is there a non-js solution that allows keyboard jumps 
 and a tree structure display for the select / option element?

 Simple & \ nbsp;  work in both Firefox (23) and Chrome (28), is there a better solution?

I am trying to create a tree selection window in css. From what I was able to find , the :before tag :before supported in IE8 + along with the content property. With that said, I can get code pending rendering in Firefox (23.0), but I can’t render it in IE (10) or Chrome (28).

HTML

 <select> <option class="level0">All</option> <option class="level1">Domestic</option> <option class="level2">Alabama</option> <option class="level1">Foreign</option> <option class="level2">Argentina</option> </select> 

CSS

 .level0:before { content:none; } .level1:before { content:"-"; } .level2:before { content:"--"; } 

Jsfiddle enabled

The reason I want to do this via css is because the client wants to restrict javascript on the page, and I would like to go to the option using the keyboard.

Any help to get her to work or to understand why she is not working will be appreciated.

* Edit: * After reading the answers in the comments (which were as good as the answers explaining why this is not possible ). I decided to use the characters &nbsp; in pure html to get the desired effect. This allows you to switch to the keyboard in both Firefox and Chrome (although I still haven't found a solution other than JS to make it work in all 3). So - since there are no answers yet - this is my new question: Is there a non-js solution that allows keyboard transitions and a tree structure for the select / option element?

+4
source share
1 answer

Why aren't you using optgroup? Are these not nested parameters in select?

http://www.w3.org/html/wg/drafts/html/master/forms.html#the-optgroup-element

I don’t know about keyboard jumps, but at least you will need to use JavaScript to navigate, not to create a list. HTML5 offers a tag, so you should use something native, such as optgroup, before trying to recreate the wheel.

0
source

Source: https://habr.com/ru/post/1496194/


All Articles