I tried this →
overflow-y: auto;
height: 100px;
Target: I want to set a vertical scroll on the left sidebar that has content.
I tried this →
overflow-y: auto;
height: 100px;
Target: I want to set a vertical scroll on the left sidebar that has content.
Your looking for scroll
when using a fixed height
overflow-y: scroll;
There’s something wrong with the codepen site, I don’t see where or how to make edits.
I tried with this one also, but it also could not create the vertical scroll.
Try just using
overflow: scroll;
EDIT:
No, that gives scrollbars each way
I tried, but that also creates a Horizontal scroll,which is not needed.
I am in chrome and can go to “inspect element”
If you set up a min-width it should work with overflow-y
overflow-y: scroll;
min-width: 200px;
height: 200px;
I tried this:
max-height: 150px;
overflow-y: scroll;
this worked, but the scroll bar was not visible. although on mouse wheel movement the content was vertically scrolling.
I got it to work with:
overflow-y: auto;
height: 100px;
I also use that in one of my sites, and it works well.
Is the element you’re wanting to give scrollbars to block level?
Applies to
non-replaced block-level elements
and non-replaced inline-block elements
I’m using it on .sidebar
and it changed appropriately in the codepen.
When you reduce viewport width you will get a horizontal scrollbar without a min-width.
He’s using flex
Hi there codeispoetry,
try it like this…
<!DOCTYPE HTML>
<html lang="en">
<head>
<!--<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src 'self';script-src 'self'; style-src 'self'">-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">
<title>untitled document</title>
<!--<link rel="stylesheet" href="screen.css" media="screen">-->
<style media="screen">
body {
background-color: #f0f0f0;
font: 1em/150% verdana, arial, helvetica, sans-serif;
}
#box {
max-width: 20em;
height: 20em;
padding: 1em;
margin: auto;
border: 0.062em solid #999;
background-color: #fff;
overflow: auto;
direction: rtl;
text-align: left;
}
</style>
</head>
<body>
<div id="box">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Curabitur sit amet sem sed libero bibendum tempus faucibus
quis mi. Nulla rhoncus vel ipsum in volutpat. Nam tortor
nibh, posuere ac lorem ut, suscipit tincidunt leo. Duis
interdum justo ac justo vehicula consequat. Curabitur et
volutpat nibh. Phasellus rutrum lacus at dolor placerat
feugiat. Morbi porta, sapien nec molestie molestie, odio
magna vestibulum lorem, vitae feugiat est leo sit amet
nunc. Curabitur ornare tempor turpis. In nibh sem, porta ac
magna sed, pretium commodo odio. Sed porttitor augue velit,
quis placerat diam sodales ac. Curabitur vitae porta ex.
Praesent rutrum ex fringilla tellus tincidunt interdum.
Proin molestie lectus consectetur purus aliquam porttitor.
Fusce ac nisi ac magna scelerisque finibus a vitae sem.
</p>
</div>
</body>
</html>
coothead
Yes, it is working.
This also worked. putting the scroll in the left like this →
#Update:
this fixes the things →
direction: ltr;
Please post a link to your updated working code
Have you tested with reduced the view port width?
overflow-y:auto
Introduces a scrollbar when it’s needed
overflow-y:scroll
Has scrollbar position in there at all times
I would still set up a min-width
Your getting a bottom scrollbar when you narrow your viewport