Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Commonmark migration
Source Link

Just a test which is working fine.

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
}
#child{
 width: 100%;
 height: 100%;
 overflow-y: scroll;
 padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
 box-sizing: content-box; /* So the width will be 100% + 17px */
}

Working Fiddle

JavaScript:

Since the scrollbar width differs in different browsers, it is better to handle it with JavaScript. If you do Element.offsetWidth - Element.clientWidth, the exact scrollbar width will show up.

JavaScript Working Fiddle

##Or

Or

Using Position: absolute,

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
 position: relative;
}
#child{
 position: absolute;
 top: 0;
 bottom: 0;
 left: 0;
 right: -17px; /* Increase/Decrease this value for cross-browser compatibility */
 overflow-y: scroll;
}

Working Fiddle

JavaScript Working Fiddle

###Information:

Information:

Based on this answer, I created a simple scroll plugin.

Just a test which is working fine.

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
}
#child{
 width: 100%;
 height: 100%;
 overflow-y: scroll;
 padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
 box-sizing: content-box; /* So the width will be 100% + 17px */
}

Working Fiddle

JavaScript:

Since the scrollbar width differs in different browsers, it is better to handle it with JavaScript. If you do Element.offsetWidth - Element.clientWidth, the exact scrollbar width will show up.

JavaScript Working Fiddle

##Or

Using Position: absolute,

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
 position: relative;
}
#child{
 position: absolute;
 top: 0;
 bottom: 0;
 left: 0;
 right: -17px; /* Increase/Decrease this value for cross-browser compatibility */
 overflow-y: scroll;
}

Working Fiddle

JavaScript Working Fiddle

###Information:

Based on this answer, I created a simple scroll plugin.

Just a test which is working fine.

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
}
#child{
 width: 100%;
 height: 100%;
 overflow-y: scroll;
 padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
 box-sizing: content-box; /* So the width will be 100% + 17px */
}

Working Fiddle

JavaScript:

Since the scrollbar width differs in different browsers, it is better to handle it with JavaScript. If you do Element.offsetWidth - Element.clientWidth, the exact scrollbar width will show up.

JavaScript Working Fiddle

Or

Using Position: absolute,

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
 position: relative;
}
#child{
 position: absolute;
 top: 0;
 bottom: 0;
 left: 0;
 right: -17px; /* Increase/Decrease this value for cross-browser compatibility */
 overflow-y: scroll;
}

Working Fiddle

JavaScript Working Fiddle

Information:

Based on this answer, I created a simple scroll plugin.

Active reading. Removed meta information (this belongs in comments).
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134

Just a test which is working fine.

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
}
#child{
 width: 100%;
 height: 100%;
 overflow-y: scroll;
 padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
 box-sizing: content-box; /* So the width will be 100% + 17px */
}

Working Fiddle

JavaScript:

Since, the scrollbar width differs in different browsers, it is better to handle it with JavaScript. If you do Element.offsetWidth - Element.clientWidth, the exact scrollbar width will show up.

JavaScript Working Fiddle

##or##Or

Using Position: absolute,

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
 position: relative;
}
#child{
 position: absolute;
 top: 0;
 bottom: 0;
 left: 0;
 right: -17px; /* Increase/Decrease this value for cross-browser compatibility */
 overflow-y: scroll;
}

Working Fiddle

JavaScript Working Fiddle

###Info###Information:

Based on this answer, I created a simple scroll plugin . I hope this will help someone.

Just a test which is working fine.

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
}
#child{
 width: 100%;
 height: 100%;
 overflow-y: scroll;
 padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
 box-sizing: content-box; /* So the width will be 100% + 17px */
}

Working Fiddle

JavaScript:

Since, the scrollbar width differs in different browsers, it is better to handle it with JavaScript. If you do Element.offsetWidth - Element.clientWidth, the exact scrollbar width will show up.

JavaScript Working Fiddle

##or

Using Position: absolute,

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
 position: relative;
}
#child{
 position: absolute;
 top: 0;
 bottom: 0;
 left: 0;
 right: -17px; /* Increase/Decrease this value for cross-browser compatibility */
 overflow-y: scroll;
}

Working Fiddle

JavaScript Working Fiddle

###Info:

Based on this answer, I created a simple scroll plugin . I hope this will help someone.

Just a test which is working fine.

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
}
#child{
 width: 100%;
 height: 100%;
 overflow-y: scroll;
 padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
 box-sizing: content-box; /* So the width will be 100% + 17px */
}

Working Fiddle

JavaScript:

Since the scrollbar width differs in different browsers, it is better to handle it with JavaScript. If you do Element.offsetWidth - Element.clientWidth, the exact scrollbar width will show up.

JavaScript Working Fiddle

##Or

Using Position: absolute,

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
 position: relative;
}
#child{
 position: absolute;
 top: 0;
 bottom: 0;
 left: 0;
 right: -17px; /* Increase/Decrease this value for cross-browser compatibility */
 overflow-y: scroll;
}

Working Fiddle

JavaScript Working Fiddle

###Information:

Based on this answer, I created a simple scroll plugin.

declare the as css
Source Link
Mosh Feu
  • 29.5k
  • 18
  • 94
  • 142

Just a test which is working fine.

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
}
#child{
 width: 100%;
 height: 100%;
 overflow-y: scroll;
 padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
 box-sizing: content-box; /* So the width will be 100% + 17px */
}
#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
}
#child{
 width: 100%;
 height: 100%;
 overflow-y: scroll;
 padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
 box-sizing: content-box; /* So the width will be 100% + 17px */
}

Working Fiddle

JavaScript:

Since, the scrollbar width differs in different browsers, it is better to handle it with JavaScript. If you do Element.offsetWidth - Element.clientWidth, the exact scrollbar width will show up.

JavaScript Working Fiddle

##or

Using Position: absolute,

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
 position: relative;
}
#child{
 position: absolute;
 top: 0;
 bottom: 0;
 left: 0;
 right: -17px; /* Increase/Decrease this value for cross-browser compatibility */
 overflow-y: scroll;
}
#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
 position: relative;
}
#child{
 position: absolute;
 top: 0;
 bottom: 0;
 left: 0;
 right: -17px; /* Increase/Decrease this value for cross-browser compatibility */
 overflow-y: scroll;
}

Working Fiddle

JavaScript Working Fiddle

###Info:

Based on this answer, I created a simple scroll plugin. I hope this will help someone.

Just a test which is working fine.

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
}
#child{
 width: 100%;
 height: 100%;
 overflow-y: scroll;
 padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
 box-sizing: content-box; /* So the width will be 100% + 17px */
}

Working Fiddle

JavaScript:

Since, the scrollbar width differs in different browsers, it is better to handle it with JavaScript. If you do Element.offsetWidth - Element.clientWidth, the exact scrollbar width will show up.

JavaScript Working Fiddle

##or

Using Position: absolute,

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
 position: relative;
}
#child{
 position: absolute;
 top: 0;
 bottom: 0;
 left: 0;
 right: -17px; /* Increase/Decrease this value for cross-browser compatibility */
 overflow-y: scroll;
}

Working Fiddle

JavaScript Working Fiddle

###Info:

Based on this answer, I created a simple scroll plugin. I hope this will help someone.

Just a test which is working fine.

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
}
#child{
 width: 100%;
 height: 100%;
 overflow-y: scroll;
 padding-right: 17px; /* Increase/decrease this value for cross-browser compatibility */
 box-sizing: content-box; /* So the width will be 100% + 17px */
}

Working Fiddle

JavaScript:

Since, the scrollbar width differs in different browsers, it is better to handle it with JavaScript. If you do Element.offsetWidth - Element.clientWidth, the exact scrollbar width will show up.

JavaScript Working Fiddle

##or

Using Position: absolute,

#parent{
 width: 100%;
 height: 100%;
 overflow: hidden;
 position: relative;
}
#child{
 position: absolute;
 top: 0;
 bottom: 0;
 left: 0;
 right: -17px; /* Increase/Decrease this value for cross-browser compatibility */
 overflow-y: scroll;
}

Working Fiddle

JavaScript Working Fiddle

###Info:

Based on this answer, I created a simple scroll plugin. I hope this will help someone.

Width and height positions confusing
Source Link
jofftiquez
  • 7.7k
  • 10
  • 71
  • 123
Loading
Wasted a lot of time on this, everyone today are using "box-sizing: border-box;" so it is really worth mentioning it inside the answer.
Source Link
gdoron
  • 150.6k
  • 59
  • 302
  • 376
Loading
added 170 characters in body
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
added 198 characters in body
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
added 8 characters in body
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
added 18 characters in body
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
deleted 4 characters in body
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
deleted 10 characters in body
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
Rollback to Revision 11
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
Plugin? Seriously? It's a script, edited to keep greenhorns on the correct path with terminology.
Source Link
John
  • 1
  • 16
  • 111
  • 199
Loading
Loading
deleted 50 characters in body
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
using unit types should be avoided when the value is zero.
Source Link
viggity
  • 15.3k
  • 7
  • 92
  • 97
Loading
added 460 characters in body
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
deleted 9 characters in body
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
added 179 characters in body
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
added 15 characters in body
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
Removed entirely redundant Fiddle that used awful practices (!important hack on every line).
Source Link
TylerH
  • 21.3k
  • 85
  • 84
  • 122
Loading
Don't use keyboard elements for non-keyboard input.
Source Link
animuson
  • 54.9k
  • 28
  • 142
  • 150
Loading
added 77 characters in body
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
Source Link
Mr_Green
  • 42k
  • 48
  • 171
  • 278
Loading
lang-html

AltStyle によって変換されたページ (->オリジナル) /