Examples get scrollbars when resizing the window and custom scaling in the os.
See original GitHub issueDescription of the problem
II noticed today all the examples currently get scrollbars as I resize them on Windows. Depending on the size they appear and disappear.
Chrome 80
Firefox 75
I’d like to suggest again that I think the default CSS for the examples should effectively be
html,
body,
canvas {
margin: 0;
width: 100%;
height: 100%;
display: block;
}
or if you want it separated
html {
height: 100%;
}
body {
margin: 0;
height: 100%;
}
canvas {
width: 100%;
height: 100%;
display: block;
}
- The height: 100% in body is needed to make sure the body covers the entire window
- The height: 100% in html is needed on firefox
And I’d suggst at a minimum the example code should be changed to
-
not have a container. AFAICT it has no point
container = document.createElement( 'div' ); document.body.appendChild( container ); ... container.appendChild( renderer.domElement );
to just
document.body.appendChild( renderer.domElement );
3 lines to 1
-
pass false to
setSize
renderer.setSize( window.innerWidth, window.innerHeight, false );
Of course I’d still suggest switching the default to do this all deeper in three and just make CSS the sizing the default and mostly get rid of the need for setSize
in most apps as somewhat suggested in #4903
In any case how you fix it or if you fix it is up to you. I just assumed you didn’t want scrollbars to appear.
Three.js version
- Dev
- r115
- …
Browser
- All of them
- Chrome
- Firefox
- [?] Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
Hardware Requirements (graphics card, VR Device, …)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:14 (7 by maintainers)
Top Results From Across the Web
scrollbar - CSS-Tricks
Get started with $200 in free credit! A brief history of styling scrollbars: It used to be a thing only Internet Explorer could...
Read more >How To Customize the Browser's Scrollbar with CSS
Firstly, we set the .scrollbar (class) width, height, background-color , then set overflow-y: scroll to get the vertical scrollbar.
Read more >How to Customize the Scrollbars on Windows 10 and 11
To change the Scrollbars height to your liking, enter a value between -120 (smaller) to -1500 (larger) for the size you want, and...
Read more >Element size and scrolling - The Modern JavaScript Tutorial
As a sample element to demonstrate properties we'll use the one given ... On a Desktop Windows OS, Firefox, Chrome, Edge all reserve...
Read more >Prevent scroll-bar from adding-up to the Width of page on ...
For example, I have a page (1) with lots of contents that overflows the viewport's (right word?) height, so there's a vertical scroll-bar...
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
Forgot to share here some investigation I did on this issue some months ago: https://github.com/w3c/csswg-drafts/issues/5260#issuecomment-726044922
Looks like changing
canvas
todisplay: block
introduced this issue. It was all fine when we were usingoverflow: hidden
. I’m partly kidding. I know we were “hiding” the issue 😛We should definitely do things “the right way” as much as we can, but I was always unsure (and still am) of exposing users to css.