I have a div with propertie overflow auto. How to make the content of this div horizontally aligned with and without the scrollbar displayed. The scrollbar is messing with the div width. I hope you understand.
            Asked
            
        
        
            Active
            
        
            Viewed 5,094 times
        
    0
            
            
        - 
                    Show us some code and we might be able to help – Tom Walters Jan 03 '13 at 13:55
- 
                    Here are simple examples: http://jsfiddle.net/ftkbL/1053/ http://jsfiddle.net/ftkbL/1054/ – Jacob Jan 03 '13 at 13:55
- 
                    Do you want to simply hide the scrollbar? Do you want the container to expand to accommodate _all_ the content? – Tom Walters Jan 03 '13 at 13:57
- 
                    I want the content to be to edge of the div not depending if there is a scrollbar or not. You can see the difference on the two examples. – Jacob Jan 03 '13 at 14:02
2 Answers
1
            
            
        overflow-x: scroll;
overflow-y: hidden;
- 
                    Something like this: http://stackoverflow.com/questions/8079187/how-to-calculate-the-width-of-the-scroll-bar – Jacob Jan 03 '13 at 15:05
- 
                    you mean the width change in function of the content size? all div are like that by default else it is not html and css anymore, you need javascript – Ricain Jan 03 '13 at 16:44
0
            
            
        Try using overflow-y: overlay instead.
.your-content{
   overflow-y: overlay;
}
NOTE::: overflow-y: overlay has been deprecated.
But this will make the scrollbar appear as an overlay without affecting the width of div or element.
 
    
    
        Vivek Kumar
        
- 2,625
- 2
- 25
- 33
 
     
    