For learning purposes, I have been playing with different css transition effects. I cannot, however, figure this bit out.
A simple setup: top nav with a toggle icon to display a sidebar <aside>
. Sidebar items are wrapped in a <div id='swap'>
. One of the sidebar items needs to be at the bottom and I have set its position to fixed. Here is the jquery:
(function() {
$(".toggle-wrap").on("click", function() {
$("i").toggleClass("fa-bars fa-times");
$("main").toggleClass("main push");
$("aside").animate({ width: "toggle" }, 200);
$("#swap").toggleClass("hidden shown");
});
})();
The click swiftly moves the main content to the right and makes the <aside>
itself visible and then makes the sidebar items visible via a transition (cubic-bezier(0.32, 1.25, 0.375, 1.15)
)
The trouble: the cubic-bezier makes a "playful" entrance but it overflows only for the fixed item at the bottom and the overflow:hidden
does not seem to have any effect. After the transition, it is perfectly in place. Here is a screenshot:
My question: How can I contain the border/prevent this overflow with the fixed position?
I used flexboxes and added a few wrapper classes. Let me know if you have any questions.
EDIT: Added border to top of
.upper
When using
position:fixed
the element will be positioned relative to the viewport and thus the overflow of its parent container won't work.To fix this simply switch to
position:absolute
and your element will be positioned relative to the nearest positioned ancestor and in your case it's theaside
element and theoverflow:hidden
of this element will hide your overflowing border.And why both values of position give the same result?
Simply because in your case, you applied only
bottom:0
and since youraside
is taking full height of the screen,bottom:0
will refer to same position which is the bottom of the screen. You may adjust slightly the height ofaside
and you will notice the difference betweenfixed
andabsolute
in this case.