Comments (1)
Hi,
Thanks for the kind words.
The short answer will be: no.
Here is some reasons:
- I think trying to mess the CSS using JavaScript is a bad practice and should be avoided ;
- If you still consider doing this, the first solution is to create a new CSS rule based on the
:fullscreen
rule(s) present in your CSS (for instance, reading#interesting:fullscreen
rule and add a#interesting:-webkit-full-screen
rule with the samecssText
). Unfortunately, browsers don't bother with invalid rules and don't create a CSSRule instance (you can try adding a#interesting:fullscreen
rule and try to read it usingdocument.styleSheets[0].cssRules
, it won't appear). So, this solution is a dead end. - Second solution, read the CSS using
window.getComputedStyle
. This method is inefficient since you have to provide an element where to read the styles. In other words, with this solution you can only handle the:fullscreen
pseudo-selector on the element going fullscreen ; there is some cases where your selector won't be directly on this element.
So, you still have to add the three CSS rules:
#interesting:-webkit-full-screen { background: red; }
#interesting:-moz-full-screen { background: red; }
#interesting:fullscreen { background: red; }
Note that you cannot group these selectors due to browser limitation.
An alternative will be to listen for the fullscreenchange
event:
document.addEventListener("fullscreenchange", function() {
document.body.classList.toggle("fullscreen");
}, false);
And the associated CSS:
.fullscreen #interesting { background: green; }
from fullscreen-api-polyfill.
Related Issues (19)
- README or Example? HOT 1
- Bower integration HOT 1
- Consider submitting a minified version to cdnjs HOT 1
- add package.json for npm support? HOT 2
- doc not defined in min version HOT 2
- webkitFullscreenEnabled HOT 1
- Support for iOS webkit HOT 4
- Should this normalize the behavior of going fullscreen? HOT 4
- Current fullscreen element is null in webkitfullscreenchange HOT 2
- Polyfill document.fullScreen HOT 2
- Make new release!
- Endless recursion on firefox HOT 2
- document.fullscreenElement is always true in Opera 12.12 HOT 1
- CSS polyfill HOT 4
- promise always pending, never update it's status HOT 2
- Add IE11 support HOT 1
- Add License HOT 2
- document.fullscreenEnabled not updating in IE 11 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fullscreen-api-polyfill.