Last active
August 29, 2015 14:10
-
-
Save nexik/0423f66405a596f99688 to your computer and use it in GitHub Desktop.
jQuery WTF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function() { | |
| var centerAbsolute = function () { | |
| $('.absolute-center').css({ | |
| position:'absolute', | |
| left: ($(window).width() - $('.absolute-center').outerWidth())/2, | |
| top: ($(window).height() - $('.absolute-center').outerHeight())/2 | |
| }); | |
| } | |
| centerAbsolute(); | |
| centerAbsolute(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Why Jquery? Why for first time $('.absolute-center').outerWidth() return the width of $(window).width() | |
| Second time returns real one? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="absolute-center" style="position: absolute; left: 0px; top: 52px;"> | |
| <div class="box white">dssd</div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .box { | |
| border-radius: 10px; | |
| box-shadow: 0 0 15px rgba(22,22,23,0.15); | |
| padding: 24px; | |
| width: 300px; | |
| height: 200px; | |
| } | |
| .box.white { | |
| background: #fff; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment