问题
I'm creating a chrome extension that displays an iframe on the top of specific pages. This iframe is fixed and placed before opening body tag.
To reserve a place for this iframe, I shift down the body including fixed element using CSS :
-webkit-transform: translateY(40px);
It seems to work fine with many websites, but on some other website such as facebook it causes a problem. a scroll bar is shown on the right side.
Is there an alternative that I might try to avoid this problem . Any help would be appreciated

回答1:
Just go one Node higher. And, you'll guess it, it's the html
element. Unfortunately, I don't know a way to access it like the body: document.body
.
But I found an easy way, use document.body.parent
.
And there, you set the css property.
document.body.parent.style.webkitTransform = 'translateY(40px)';
Just besides, margin-top
works too:
document.body.parent.style.marginTop = '40px';
来源:https://stackoverflow.com/questions/17305278/an-alternative-to-webkit-transform-transformy