html - Make div scrollable no scrollbar -
once again have read many posts on topic none of suggested solutions work. have solution, however, not know why works , appreciate insight.
below solution found on so: hide scroll bar, while still being able scroll
html
<!doctype html> <html lang="en"> <head> <title>testing</title> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> </head> <body> <div class="hidden-xs hidden-sm col-md-3" id="parent"> <div id="child"> test text here </div> </div> </body> </html>
css
#parent { padding: 0px; border-width: 1px; border-style: solid; height: calc(100vh); overflow: hidden; } #child { width: 100%; height: 100%; overflow-y: scroll; padding-right: 17px; /* increase/decrease value cross-browser compatibility */ }
the above not work me scroll bar remains visible. however, have found property on page parent element "box-sizing" when changed other "border-box" scrollbar disappears , scrolling works expected.
according browser, css comes bootstrap.sass gem.
* { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
my 2 questions are: 1) why case? 2) how turn off in css file?
a scrollbar placed on edge of element's box, should inserted between inner border edge , outer padding edge. space taken scrollbars should taken out of (subtracted dimensions of) containing block formed element scrollbars.
- the
content-box
(default is) means element's content box values of it's width property, , width of border or padding added final rendered width.; - the
border-box
means tells browser account border , padding in value specify width , height.
you can add code:
#child { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
Comments
Post a Comment