How to add margin or padding to a scroll - css

I have a div. Inside it some other divs. In styles I have rule overflow: auto;
And it works well. But I want a padding or margin on the left side from this scroll. How could I make it?
Thank You!

Related

CSS Issue - Scroll on bottom box margin

Trying to apply margin-bottom to the box looking like this:
It seems like when you have overflow: auto or scroll; it just cuts off text like this, and applies margin on the bottom on the element. Any way I can make this margin before someone scrolls down?

How to block scrolling without "jumping"

Well i know about overflow-y: hidden, but I dont like that my site "jumps" to the right side like for 20px every time i use overflow-y: hidden.
Is it possoble to block scrolling without "jumping"?
here is example http://jsfiddle.net/wjyb8tzw/6/
Just give a margin or padding of 20px at the right side.
padding-right:20px;
The line overflow-y disables the scrollbar on the right, this changes the maximum width of the webpage.
The line margin: auto centers the div based on the maximum width of the webpage, therefore disabling the scrollbar moves the div a little to keep it centered.
If you specifically don't want the div to be centered then use margin-left: -17px; as the width of the of the scrollbar is 17 pixels as stated here.

nested (div) acting up

I know the solution is very simple, but I have come here for help to get the answer quickly I hope. So I have my page set up with Divs and I have a "content" div and with in that content div I have a contentarea div, so here is the problem I have run into: I want to position the "contentarea" div in the content div, the "contentarea" div will be centered in the content div with a little margin on the top and bottom. The problem is when I set the margin "top" for the contentarea div the the "contentarea div" is not actually moving but the content div itself is moving, and creating white space between the menu. Some how the contentarea div when moved, moves the content div. Any solutions? I want the content div to stay where it is when I position my content area div!!
For the main div use:
overflow: auto;
Or overflow visible :). U can also set padding on the main div :).
Best regards!
If you don't want to use overflow, you can do the trick with padding, look at this code :
Exemple :
.contentdiv {
padding-top: 10px;
}
Or
.container {
padding-top: 10px;
}
The full exemple : http://jsfiddle.net/Ca4K2/

Having a CSS fighting itself issue

I have a "Content" div, which within itself contains 3 divs that float:left. Below that is the footer.
Now the footer has a border-top:10px which you'll see is hidden behind the content div. This is because the content div does not adjust it's height because it's content is floating.
To fix this I do
overflow:hidden
Here's the problem, while this fixes the height problem, it causes another issue.
The 3 floated divs have a box-shadow on them, and when the "content" container's overflow is hidden, it chops off the outside shadows.
Here's the jsfiddle http://jsfiddle.net/rhPCE/2/ as you'll see, the box-shadows are chopped off on the outside, and if you remove the overflow:hidden; from #content it fixes the shadows but breaks the positioning of the footer div.
Any ideas?
Thanks in advance!
When you float elements, the parent container naturally collapses because floated elements exist outside the normal document flow.
To fix this, you can apply a clearfix to the #content container:
Remove overflow: hidden; from #content
Include a clearfix, such as this: A new micro clearfix hack
Apply the clearfix class to the #content div, like this: <div id="content" class="cf">
After this, your parent container #content will expand to the height of the tallest floated element.
Working Example: http://jsfiddle.net/rhPCE/3/

Padding in a div where other divs are floated

Here is the JSFiddle link:
http://jsfiddle.net/stapiagutierrez/48yGU/34/
When I use padding: 10px; on the #middle div, I thought it would make the contained divs inside become smaller to fit the padding.
This is partially true, it's pushed from the top and left/right, but it's overflowing from the bottom.
Any explanation for this, and a solution for this common case? So far, I've used overflow: hidden; but this feels like a hack. But maybe since I'm new to CSS this is how you're supposed to handle it.
You need to add clear after the floats like this: http://jsfiddle.net/48yGU/38/
Edit: the reason its overflowing from the bottom is because float does not have size. so the container thinks there is nothing there and just draws the padding on both sides (thats why it looks line height). what clear does is it sticks to bottom of floats and have size, so its pushing the container bottom to the bottom of the floats.
It's because the floated DIVS are positioned out of the normal flow, in which padding would normally consider the height and width of contained elements.

Resources