Read the statement by Michael Teeuw here.
`center` region problem.
-
@sean the
position:fixedproperty won’t work because it has a CSS transform applied. This is a limitation of CSS. What are you trying to achieve with your positioning? Maybe I can suggest a different way. -
@j-e-f-f
Yes I knowposition:fixednot working due totransform. But I need it. :(
My goal is openpopuplayer.
The html structure will be like this.< div class="region top center" > < div class="container" > < div module id="SOMETHING" class="module ... " > < div id="MY_NORMAL_CONTENT" > .. < /div > < div id="MY_OVERLAYED_CONTENT" class="hidden or showing" > ... < /div>I want to draw
#MY_OVERLAYED_CONTENTas some kind of popup. In all regions exceptcenterit could work perfectly, but not incenter.I also know it can be achieved if my MY_OVERLAYED_CONTENT is appended into
bodydirectly, But as you know, it is not so graceful. Whenmodule.show()andmodule.hide()is called, that parts which appended intobodydirectly should be mangaed in.suspend()and.resume(). I don’t want it just for positioning incenterregion. -
@sean You don’t need
position:fixed.position:absolutewill work just as well, since the composition never scrolls. The only caveat is that you will need to ensure that thedivwith the idMY_OVERLAYED_CONTENTis attached to the document root instead of as part of your module. e.g.:var overlayDiv = document.createElement("div"); overlayDiv.setAttribute("id", "MY_OVERLAYED_CONTENT"); ... document.body.appendChild(overlayDiv);This also gives you the advantage of your overlay element being the last item in the draw order meaning that it will layer on top of everything else by default. No need to futz around with
z-indexwhich can be a real pain in the bum. -
@j-e-f-f
Yes. That might probably be one solution. But for module hiding, I need to add the codesuspend: function() { var overlayDiv = document.getElementById("MY_OVERLAYED_CONTENT") overlayDiv.classList.add("hidden") }And also for module showing. (resume())
So I just wanted to know any CSS trick to escape prior transform appliance.
-
@sean You would have to override the CSS to remove the transform, but it may give you unexpected results elsewhere and maybe cause havoc with other modules. I would avoid overriding MagicMirror’s core structure.
Your idea to add and remove the hidden class in suspend and resume should work fine. Just don’t create the overlay element as part of the
getDom()routine. Create it outside of that, and keep a reference to it in your code. That way you don’t have to make repeated DOM lookups, and you’ll be able to update the container from anywhere in your code at any time. -
@j-e-f-f
Thanks for your instruction. I already have been using those tricks in my modules. Just wanted to know other way to achieve. :D
