CSS overflow-x: visible; and overflow-y: hidden; causing scrollbar issue
After some serious searching it seems i've found the answer to my question:
from: http://www.brunildo.org/test/Overflowxy2.html
In Gecko, Safari, Opera, ‘visible’
becomes ‘auto’ also when combined with
‘hidden’ (in other words: ‘visible’
becomes ‘auto’ when combined with
anything else different from
‘visible’). Gecko 1.8, Safari 3, Opera
9.5 are pretty consistent among them.
also the W3C spec says:
The computed values of ‘overflow-x’
and ‘overflow-y’ are the same as their
specified values, except that some
combinations with ‘visible’ are not
possible: if one is specified as
‘visible’ and the other is ‘scroll’ or
‘auto’, then ‘visible’ is set to
‘auto’. The computed value of
‘overflow’ is equal to the computed
value of ‘overflow-x’ if ‘overflow-y’
is the same; otherwise it is the pair
of computed values of ‘overflow-x’ and
‘overflow-y’.
Short Version:
If you are using visible
for either overflow-x
or overflow-y
and something other than visible
for the other, the visible
value is interpreted as auto
.
CSS overflow-x hidden and overflow-y visible
You can do this with CSS like this:
HTML:
<div class="wrapper">
<div class="inner">
</div>
</div>
CSS:
.wrapper{
width: 400px;
height: 300px;
}
.inner{
max-width: 100%;
overflow-x: hidden;
}
Now your .wrapper
div will have overflow: visible;
but your .inner
div will never overflow because it has a maximum width of 100% of the wrapper div. Note that your wrapper must have an explicitly defined width.
Here is a working jsFiddle
Overflow y hidden breaks overflow x visible
So the only way I could get this working was to set the position of the blue box to be fixed and then using JavaScript to change the top and left values on document ready and window resize.
Fiddle here: http://jsfiddle.net/3dhdy9e9/15/
Code:
function positionBox(){
var left = $('#theBox').offset();
left = left.left;
var top = $('#theBox').offset();
top = top.top;
$('#theBox').css({ 'position': 'fixed', 'left': left, 'top': top });
}
$(document).ready(function(){
positionBox();
$(window).resize(function(){
positionBox();
});
});
overflow-x: scroll and overflow-y: visible alternative
This is actually a complex and long-standing problem. Solving it with CSS alone is not feasible.
The trick is to pluck the active element out from the static context and force it to be fixed to the viewport when hovered over. I tried to boil this down to a minimal reproducible example but the more I hacked away at it the more quirks I encountered. With fixed image sizes you can accomplish this with a pretty minimal amount of scripting but there are some usability issues and the more of them I fixed, the more complex the code got.
Ultimately, what I ended up doing was publishing a custom element that handles all of this automagically.
Using it is dead simple:
over-scroll {
width: 50%;
margin: 3rem auto;
}
pop-out img {
height: 100px;
width: auto;
}
<script type="module" src="https://bes.works/bits/bits/pop-out.js"></script>
<over-scroll>
<pop-out><img src="https://picsum.photos/720/480"></pop-out>
<pop-out><img src="https://picsum.photos/480/720"></pop-out>
<pop-out><img src="https://picsum.photos/500/500"></pop-out>
<pop-out><img src="https://picsum.photos/640/480"></pop-out>
</over-scroll>
overflow-x: visible; doesn't work with overflow-y: auto; any workaround?
You cannot, that is written in the spec.
Have a look here : https://stackoverflow.com/a/6433475/1343096
Since it is written in the spec, I am 99% sure that it is impossible to do.
overflow-x:hidden; won't work but overflow-x:scroll; will?
Setting overflow:auto
will fix your issue this will add scroller on when the width exceeds
.dataTables_wrapper{
overflow:auto; /* set overflow auto */
background: #1B1E24;
}
Related Topics
How to Put CSS @Media Rules Inline
Fixed Headers on Scroll Inst Working Correctly in Angular Application
How to Adjust the Width of the Input Field Based on the Placeholder Text
How to Disable a Text Area or Mat-Form-Field
Bootstrap Toggle Collapse Is Not Working
How Change Text and Color of Button Browse of Input File
Favicon Not Showing Up in Google Chrome Browser
Splitting the HTML Page Using Div
Text Cutting Inside Large Select Option Dropdown
Input Type Date Appearance in Safari on Ios
Mp4 Video Is Not Playing on Mobile Devices and Chrome
Img Src Tag Not Displaying Image
Rendering HTML Content With @Html.Raw in Razor Mail Template
How to Prevent VS Code from Breaking Up Long HTML Lines into Multiple Lines
How to Limit the Visible Options in an HTML <Select> Dropdown
How to Dynamically Add HTML Element/Content - Angular
How to Remove Blue Highlight on Hover in Select, Option Inputs HTML for Chrome