checkbox - Is it possible to use HTML5's details tag in lieu of the check box hack? -


i love checkbox hack. isn't knock on checkbox hack at all, i've run situations cannot use checkbox hack because of limitations put in place cms.

in theory, think <details> , <summary> tags used mimic checkbox hack. tabbed areas, example, created checkbox hack, i'd think recreated using styled details. likewise burger menus, push toggles, etc.

i've never seen done anywhere, though, makes me wonder if trying exercise in folly. or, checkbox hack preferred alternative jquery in these instances?

so, question remains same: possible use <details> tag recreate can checkbox hack? , if not, why not?

i've run situations cannot use checkbox hack because of limitations put in place cms.

as @wayne indicates in comment above, can't use use <details> / <summary> in either ie11 (or before) or in edge 14/15/16.

see: http://caniuse.com/#feat=details


however, there technique can use in place of checkbox hack - :focus pseudo-class.

  • many elements can take focus, once given tabindex.
  • any element has focus can targeted in css, using :focus pseudo-class.

working example:

h2 {  position: relative;  z-index: 6;  cursor: pointer;  }    p {  position: relative;  z-index: 3;  opacity: 0;  transform: translatey(-44px);  transition: opacity 0.2s linear, transform 0.6s ease-out;  }    h2:focus + p {  opacity: 1;  transform: translatey(0);  }
<h2 tabindex="0">i heading. click me.</h2>    <p>i paragraph. appeared because clicked on heading above.</p>


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -