Wrong vertical center
See original GitHub issueHey, I have an issue with the latest version (1.0.9), the images don’t appear in the middle of the screen because the windowCenter function returns a “wrong” value, if I change the code to the one below it does take the correct windowCenter:
function getWindowCenter() {
var docWidth = docElm.clientWidth || body.clientWidth;
var docHeight = window.innerHeight; // this didn't work: docElm.clientHeight || body.clientHeight;
return {
x: half(docWidth),
y: half(docHeight)
};
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Why is vertical-align: middle not working on my span or div?
I'm trying to vertically center a span or div element within another div element. However when I put vertical-align: middle , nothing ...
Read more >Understanding vertical-align, or "How (Not) To ... - Phrogz.net
This question is often followed by I'm using vertical-align:middle but it's not working! The problem here is three-fold: HTML layout traditionally was not ......
Read more >15 ways to implement vertical alignment with CSS
1. Absolute positioning and margin: auto · 2. The classic top:50% , translateY(-50%) · 3. Centering with tables · 4. The ghost element...
Read more >How To Center an Element Vertically - W3Schools
Learn how to center an element vertically and horizontally with CSS. I am vertically and horizontally centered. ... <div class="vertical-center">
Read more >CSS Vertical Align for Everyone (Dummies Included)
I'm having problems centering my content. It's bad, really bad. I couldn't sleep. And you know what? Everyone's struggling with this, it can...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The current implementation is below:
Notice it’s not perfect though, in modern browsers, it will give you the window center that either excludes scroll bar width and height, which are the desired values, or includes scroll bar width and height (
window.innerWidth
andwindow.innerHeight
).References:
It works!