There are multiple questions named this way, but I didn't find one that applies to my case, so here I am:
In this snippet:
#container:hover {
overflow-x: hidden;
}
#container {
position: relative;
width: 400px;
height: 40px;
background: red;
margin: 2em;
}
#child {
position: absolute;
bottom: 0;
}
<div id="container">
<div id="child">
a<br/>
b<br/>
hover<br/>
me
</div>
</div>
You can see that overflow-x, which is applied when you hover the red box, will also hide the overflow-y (at least on Chrome). This is annoying because I have a tooltip that I would like to be able to overflow above the red box, and in the meantime I have a menu that will slide from the right side and that should stay hidden.
Is this a bug? Is there a workaround?
You can't change the way overflow-x and overflow-y behave (it's the same in Firefox and other browsers), but you can change the way your HTML is organized.
Put everything that you want to hide when overflowing in a single wrapper. Put your tooltip in another wrapper.
Something like this may suit your needs:
#container {
position: relative;
width: 400px;
background: #f77;
margin: 3em 2em;
}
#child {
overflow: hidden;
position: relative;
}
#menu {
position: absolute;
left: 100%;
top: 0;
background: #dd2;
transition: .2s;
}
#child:hover #menu {
transform: translateX(-100%);
}
#tooltip {
position: absolute;
bottom: 100%;
}
<div id="container">
<div id="child">
hover<br/>
me
<div id="menu">
menu
</div>
</div>
<div id="tooltip">
a<br/>
b
</div>
</div>
Is the clipping behavior a bug?
No, the clipping is in accordance with the spec.
UAs must clip the scrollable overflow area of scroll containers on the
block-start and inline-start sides of the box (thereby behaving as if
they had no scrollable overflow on that side).
In your case, the "block-start" side is the top, and the "inline-start" side is the left. That's why you can put your tooltip below the content, and it will trigger a scrollbar.
#container:hover {
overflow-x: hidden;
}
#container {
position: relative;
width: 400px;
height: 40px;
background: red;
margin: 2em;
}
#child {
position: absolute;
/* bottom: 0; */
top: 0;
}
<div id="container">
<div id="child">
hover<br/>
me<br/>
a<br/>
b
</div>
</div>
So why is it possible to scroll to content overflowing below the box, but not possible to simply make it visible? The reason is that when any overflow property is set to hidden, the entire box becomes a scroll container.
[A scroll container] allows the user to scroll clipped parts of its
scrollable overflow area into view.
You can use overflow: clip, which does not turn the box into a scroll container. If you clip in both direction, you can also adjust the distance at which clipping occurs as well using overflow-clip-margin :
#container:hover {
overflow-x: clip;
}
#container {
position: relative;
width: 200px;
height: 40px;
background: red;
margin: 2em;
}
#child {
position: absolute;
bottom: 0;
}
<div id="container">
<div id="child">
aazkopekzapoekzapoekzapoekzapoekpozakepozakepozakeoza<br/>
b<br/>
hover<br/>
me
</div>
</div>
Related
I'm currently trying to make it so that whenever I hover over the div with class hover-me, the div with class popup will change from being hidden to being shown. This works fine, however, the div with class popup is absolutely positioned outisde its parent div with class element but because the div with class elements-container has overflow-y: auto and overflow-x: hidden, I can't see it.
I'm wondering if there's any trick I can use to fix this problem without actually removing the overflow-y and overflow-x from elements-container, because that would break some other stuff.
So I have the following structure right now:
<div class="elements-container">
<div class="element">
<div class="hover-me">Hover Me</div>
<div class="popup">Hello</div>
</div>
<div class="element">
<div class="hover-me">Hover Me</div>
<div class="popup">Hello</div>
</div>
</div>
And the following CSS:
.elements-container {
overflow-y: auto;
overflow-x: hidden;
}
.hover-me {
position: absolute;
top: 0;
left: 0;
width: 30px;
height: 30px;
z-index: 99999;
}
.hover-me:hover > .popup {
display: block;
}
.popup {
position: absolute;
background: #242528FF;
border-radius: 3px;
width: 200px;
left: -200px;
top: 0;
color: white;
display: none;
}
I have a fixed size, scrollable parent div containing two children: The first contains the content, and should determine the size of the scrollable area. The second is small overlay that is moved around dynamically, and should not affect the size of the scrollable area. That is, if the overlay overhangs the bottom edge of the content, and the user scrolls all the way down (assuming the content is larger than the parent div), scrolling should stop once they hit the bottom of the content, even if that means only part of the overlay is visible.
Is this possible to achieve?
E.g., with this HTML:
<div id="parent">
<div id="content">
<img src="640x423_image.jpg">
</div>
<div id="overlay"></div>
</div>
and this CSS:
#parent {
position: relative;
height: 400px;
width: 400px;
overflow: auto;
border: 1px solid red;
}
#overlay {
position: absolute;
height: 20px;
width: 20px;
background-color: lightblue;
top: 413px;
left: 15px;
}
(JSFiddle), the browser lets the user scroll past the bottom of the content until the entire overlay (the blue square) is visible, while I would like it to stop once the bottom of the image is visible, leaving the bottom 50% of the overlay still hidden.
For my use case, I am able to make adjustments to the HTML if necessary.
Put square box and img inside same container (#content in your case), and set overflow: hidden; on it.
#parent {
position: relative;
height: 400px;
width: 400px;
overflow: auto;
border: 1px solid red;
}
#content {
overflow: hidden;
position: relative;
}
#overlay {
position: absolute;
height: 20px;
width: 20px;
background-color: lightblue;
top: 413px;
left: 15px;
}
<div id="parent">
<div id="content">
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAFBQUFBVUFpkZFp9h3iHfbmqm5uquf/I18jXyP////////////////////////////////////////////////8BUFBQUFVQWmRkWn2HeId9uaqbm6q5/8jXyNfI///////////////////////////////////////////////////CABEIAacCgAMBIgACEQEDEQH/xAAYAAADAQEAAAAAAAAAAAAAAAAAAQIDBP/aAAgBAQAAAADnG4vowbzG0y3fNV4o16crpU2QkqdZuiWm+eL6JBMZDuJSw0DSiOd2QLTUmZllzchaxH0isptmOmGxSigQN80b6IBA41JM4z2ktXjkO04vSs1FICiL1wg03mqljdYXn0BDqUBc809NyyUMTJRk7RU6c8UrlBoOFQ5LUUZj6kiqAFA9QiqSBVHOutDQIjRCh4bKNAfOm6kqW3Fzcgo6DBGnVlcU3SM0rsSZSQzPF9kAIJLZOeRaWooyWsJ0yGTRtlRC1jMN2a522qrm0y6B5sYItYZ67xQIuHSMpw2I0pnPBrMMdJDTpOsNXgF6jb0G87wudWoZVZhb5J6xUMVZXUqIz3WHSkcobZXAOWFVGjmN8cx9VYWXaQ4J1pKWUkNvjrrhsps59KlHLsTn0xMYl3FPPSHFgJ1n0rlDTdQ9FQ6zx0Ww87TqUqefPr0Z0FO559GSc3ZnnlsljJrNCm7zSGqRXThgPXowudoubrLGq3UjToi2ckb6puabWNjnF65zO6z5x6xoKnlNDeW0xtvwo001lDm1dYwb2ZaSmxbOOJ9cUVJVRnak5d3MFmWZdjBqG87jQhamAb7Z6Z6rOzTKZvcWVIoVWZc3RZaAsyTM4jUeOtnLBprDHJDCo6Iyvbk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M2S1HCJYfefH7xY3h9cFhkS+a4LhLNjI95Yus0NURFiyyybt4QssXKfWILQ3SePHhZ7kTEXhD7eYe8vEnzQ+CHhfR74MiXyseEy83ldCLRePkfIssssm8zlrEeuG0iJLsXY8IfbzHvF5f2L6m83lfUnwbyuV4vLYu8T5SehdDIj5Lv6n914v8AoPCy/uYu8Psjmyx5WXwXB/Q+C/418bw3i8L71wf2L7b5X9bf02XjReKKHhfQua/u1/XWHworNDwuvseVl/auNfWs3xvhvi+F8tl5eFyrhZY/tfJZv/hXi+Flll/1N/1LL+topi4ULNYpizrNFFcHmuFfTXFL94f9DT5bwvrrF539eyhrFcXrFor6nimUkXl/Q/o6eUWP7/R6KwiilijYi2PjZrKebwyy89vnZbKbxf2V/QWVzXLvLd5f/priudovlX0W/wCokltiwuV/V0a5rHRa4UihcL4b+my839lcq+yvrby8oVm7ymXfrlZfFGsaLNF4s0NYfF/2lzrksddZvFmsJ2MT5XwVfS8t8KX7/r64P7axeLviimW8Xy0f+PO7GWbLKy8rlf8Abv6VwsvhZYxF6O+V49YYiuK4b+l81/wKZvhZXG+LWGexl42PNZZviy8X/wAOjrFNf1ErKxWNI7zQjRZY+i8XzvNPNcv/xAAUEQEAAAAAAAAAAAAAAAAAAACg/9oACAECAQE/AAcf/8QAFBEBAAAAAAAAAAAAAAAAAAAAoP/aAAgBAwEBPwAHH//Z">
<div id="overlay"></div>
</div>
</div>
I want horizontal overflow and when the screen width is not that wide the DIV starts scrolling right - left, but I want it to look not that ugly I have it right now (scrollbars in the bottom of the div).
.wrapper {
position: relative;
overflow-x: scroll;
overflow-y: hidden;
}
.content {
margin: 0 auto;
width: 1198px;
}
HTML
<div class=wrapper>
<div class=content">
My content here..
</div>
</div>
And the other question - is there setting for CSS what allows "swipe" for the div instead of "drag and move".. ?
For a pure CSS solution with browser support you could use the combination of ::-webkit-scrollbar and some padding like this:
.wrapper {
width: 100%;
height: 400px;
position: relative;
overflow: hidden;
}
.content {
width: 100%;
height: 100%;
overflow: auto;
padding-right: 17px; /* This hides the right scrollbar */
padding-bottom: 17px; /* This hides the bottom scrollbar */
}
.content::-webkit-scrollbar {
display: none;
}
<div class="wrapper">
<div class="content">
<img src="https://via.placeholder.com/1500x700" />
</div>
</div>
Better to play around with in JSFiddle: https://jsfiddle.net/thepio/pavb2hfy/
I'm trying to have an child element (something like a toolbar) of a parent element to be positiond on its bottom edge. The bahavior should be the same as using position fixed for the browser view.
I'm using absolute position right now. Everyting is perfect until the parent needs to scroll its content. Then the toolbar moves along with the rest of the parent's content.
Could somebody explain me why the toolbar moves?
Is it possible to achieve that task without need any javascript?
* {
box-sizing: border-box;
}
.container {
position: relative;
width: 100px;
height: 150px;
overflow-y: auto;
border: 1px solid black;
}
.mock {
height: 200px;
background-color: red;
}
.tool-bar {
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 40px;
background-color: blue;
}
<div class="container">
<div class="mock"></div>
<div class="tool-bar"></div>
</div>
The toolbar is inside the scrollable area, that's why it scrolled. Try this code:
HTML
<div class="container">
<div class="scroll">
<div class="mock"></div>
</div>
<div class="tool-bar"></div>
</div>
CSS
div.scroll { /* style of .container to scroll */ }
I have found an interesting fiddle that may help you. They are using position:fixed and the divs are not nested:
http://jsfiddle.net/b2jz1yvr/
<div class="fixedContainer">
This is experimental
</div>
<div class="otherContainer"></div>
.fixedContainer {
background-color:#ddd;
position: fixed;
padding: 2em;
left: 50%;
top: 0%;
transform: translateX(-50%);
}
.otherContainer {
height:1000px;
background-color:#bbb
}
This question already has answers here:
CSS overflow-x: visible; and overflow-y: hidden; causing scrollbar issue
(9 answers)
Closed 6 years ago.
When I set overflow-y on a block, it seems to be affecting the overflow-x property. I've made a JSFiddle with an example of this problem. It seems to be happening in all browsers, so I think I'm missing something that should be obvious.
I have two non-overlapping blocks (blue and green) along with a third block (red) with the following requirements:
The blue and red blocks are adjacent
The red block is contained in the blue block, but it overlaps the green block
The blue block must allow vertical scrolling, but not horizontal scrolling
However, if I set overflow-x: visible so the red block overlaps to the right, instead it behaves as though I set it to scroll. However, if I remove the overflow-y property or set it to visible, the red block behaves as I expect.
I do need vertical scrolling, so I'm at a loss for what to do.
With the code below
HTML:
<div id="container">
<div id="left">
<div id="floater"></div>
</div>
<div id="right">
</div>
</div>
CSS:
#container {
height: 200px; width: 200px;
position: relative;
background-color: #ccc; border: solid 5px black;
}
#left {
position: absolute;
top: 0; left: 0; bottom: 0; width: 100px;
overflow-x: visible;
overflow-y: auto; /** REMOVING THIS CHANGES THE RESULT **/
background-color: blue;
z-index: 2;
}
#right {
position: absolute;
top: 0; right: 0; bottom: 0; width: 100px;
z-index: 1;
background-color: green;
}
#floater {
position: absolute;
right: -20px; top: 30px; height: 40px; width: 40px;
background-color: red;
}
See: CSS overflow-x: visible; and overflow-y: hidden; causing scrollbar issue
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.