In many of the pages on my blog, I have a structure that consists of boxes with a link like this:
http://jsfiddle.net/gliu/E32Bh/
The issue I'm facing is that when too much text is added to these boxes, a vertical scrollbar appears only upon hovering over them. However, this scrollbar creates its own margin which affects the text wrapping.
Is there a solution to prevent the scrollbar from affecting text wrapping while still allowing users to scroll through the DIV? Ideally, I don't want the scrollbar to be hidden, but if that's the only solution, I'm open to it. Any pure CSS/HTML solution to this problem would be highly appreciated!
Here is the code snippet:
<p>You can see how the text wraps differently when you hover over the div:</p>
<div id="scroller">
<div class="content">
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of et...
The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
</div>
</div>
div#scroller {
position: absolute;
width: 75%;
height: 50%;
margin: 0;
padding: 0;
background: black;
color: white;
overflow: hidden;
border: 3px solid gold;
}
div#scroller:hover {
overflow-y: scroll; /* Display scrollbar on hover only */
}
div.content {
padding: 1em;
background: transparent;
}