How to Stop Jumping Position fixed element on scrolling - javascript

Please anybody help spend 3 days on this but still stuck. I created a section on my site where am playing video-based scroll position to section but when you scroll to the first section or back to the last section from the bottom side video frame jumps.
actually, I don't know how I make position fixed element to top:0 inside relative container currently I have video frame position: absolute which is top:0 and correct but when I scroll am changing position:absolute to position fixed but that can't work with top:0 because fixed element can't work to the relative container so am adding top:35%
please watch the video here
https://www.loom.com/share/c29a3cadb3dc4420a59baaae072c1cec
and here is the site link
https://qa.modulos.ai/product-overview/

Okay I found your solution!
Remove everything that you have, and remove those classes not-sticky-top and sticky not-sticky-bottom
And your main problem is that body has overflow: hidden; which you must remove so that sticky can work, like this link says
Change your css like this:
body {
overflow-x: visible;
}
.sticky {
position: sticky !important;
top: 100px; // This is important so that the video doesn't go under the header, you can fine tune it afterwords
max-width: 100%;
}
.video-side {
position: relative;
}
Don't forget to remove over-flow: hidden on body and remove all those JS triggers and all other classes on the video element

Related

Sticky position on Wordpress site

I'm trying to make a sticky element in my website that it's made in wordpress with a custom template.
I was trying everything, from css (position: sticky) should work. But in my case is not.
Can you help me with this issue?
This is the structure of the page, on the left the sticky element that I want. On the right, the content
Thank you you very much for your time.
I have checked your code.Position sticky is not working as because one of the parent div has overflow:hidden property so basically position sticky is not working with overflow hidden so please apply below property in your css file and then check
<style>
aside.widget-area.col-xs-12.col-sm-12.col-md-4.col-lg-3.order-2-sm-sidebar {
position: sticky;
top: 80px;
height: 600px;
overflow-y: scroll;
}
#widthContent {
overflow: unset !important;
}
</style>

Fixed element in -webkit-overflow-scroll is not actually fixed with iOS safari

I have a fixed footer with scroll and fixed element inside the footer like bellow.
.footer {
position: fixed;
overflow: scroll;
-webkit-overflow-scrolling: touch;
}
.footer .fixed {
position: fixed;
}
When I scroll the footer, the fixed element inside the footer bounces.
Here is my jsbin. Please access with your iPhone/iPad.
https://output.jsbin.com/wiyewi
Scrolling the bottom red area makes blue square element bounce. With iPad, it moves really big.
As you can see in the input, the element's DOM position ($('blue').position().top) does not change at all. Only the 'visual element' is moving.
Does anyone know how to fix this? I know there are some similar question but none of them are answered...
-webkit-overflow-scrolling touch doesnt work with fixed elements
Position fixed and -webkit-overflow-scrolling: touch;

CSS: absolute element inside an another absolute element

I create a big div (div1 in the Fig 1.1) and set it to position: absolute. This div is the content container of the page, and inside this div are all the other elements. My reason to do absolute this div is for remove the bounce on scroll in browser:
Remove bounce on scroll in browser solution
My problem, is if I have other absolute divs inside the big one. In the Fig 1.1 can see the div2 with position:absolute, and if the div1 is scrolling, the div2 conduct is like a fixed element. Div2 is only an example, I have a lot of absolute elements like Popovers that to be relative is not an option.
How can I say to div2 (in the Fig 1.1 example) that when div1 scrolls moves along with page scrolling?
Code example
html, body {
height: 100%;
overflow: hidden;
}
.div1 {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow: auto;
}
div2{
position: absolute;
}
Image Example (Fig 1.1)
Correct way
I know that exist a lot of related answers, but all of them is quite different to my question.
Related questions:
Absolute positioning inside absolute position
CSS: Absolute Element inside Absolute Element
I have other solution. To fix iPad overscroll I wrote a small script, that fixes "scroll bouncing" / "overscroll"
https://github.com/aiboy/PerfectScrollFix
First of all, you don't need to change layout drastically and use absolute div's. Second, scroll is remains to be "native".
There is two problems thou:
1) For now only horizontal overscroll fix is supported
2) Your content ( that will be scrolled ) should be wrapped in a single element (wrapper)
You can test this script on iPad: http://jsbin.com/usomob/4
Source code of Example http://jsbin.com/usomob/4/edit

CSS/HTML - Floating DIV when I scroll issue

I have what seemed like a simple issue but cant quite figure this one out. I am using bootstrap version 3 to create my base layout. I have a footer that needed to be at the bottom of the page so i made it position: absolute; bottom: 0; and worked fine if I zoom out. When the content start getting lengthy it creates the vertical scroll bar and when scrolling the DIV floats around instead of staying at the bottom.
I tried giving the container a position: relative; but dosent seem to do anything. Would anyone have any ideas?
Heres an example of my layout, if you resize the preview section to force the vertical scroll bar you will see that when you scroll the DIV floats around instead of staying in place.
https://jsfiddle.net/DTcHh/10301/
try with fixed
.footer {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
}
js fiddle example
non-fixed, see the below:
your problem is (from what I gather) the footer is floating dependent on the content and and you want it to stay put where you call it.
.footerElement {
// base styles all styles
display: inline-block; // add this, does as you imagine
}
"Displays an element as an inline-level block container. The inside of
this block is formatted as block-level box, and the element itself is
formatted as an inline-level box" -W3schools
scrollbar, see the below:
As for the element that has a scrollbar resolving.
.elementwithScrollbar {
// base styles all styles
overflow:hidden; // or use overflow-y:hidden; or x
}
fixed, see the below:
If you want it to be fixed; adding position: fixed; and the value coordinates should all you have to do there. (ie. position:fixed; and where you want it)
"Do not leave space for the element. Instead, position it at a
specified position relative to the screen's viewport and don't move it
when scrolled. When printing, position it at that fixed position on
every page." -MDN
Using fixed only anchors it to the bottom of the screen regardless of which part of the page you are viewing. I think you want to have the footer at the bottom of the page rather than constantly sitting at the bottom of the screen.
To fix, amend your spelling mistake here:
.contrainer-fluid { <-- should be container
position: relative;
}

css margin issue with jquery slider

I've having an issue with the background images i have embedded into my carousel. click here I've noticed when i click from one slide to another the background image on my site moves out of place. The margin-top for my carousel is current set to margin-top:-275px; and the background image is set to margin-top:-64px; I am slight concerned about these settings.
Does anyone have a solution to this problem?
In order to activate the slides click the thin red tab under the nav bar
I guess that's because you have
.rslides li {
top:0;
}
It does nothing with position:relative (and the current slide has it), but it moves down the slide with position:absolute (hidden slides).
When you click a tab, there's a moment in which the new one is fading in, but it doesn't have position:relative yet. Then, in that moment, the new slide isn't where you want.
So remove that line.
The jumping is occurring because you are switching the LI items from position: absolute; to position: relative; at the end of the animation toggle. This can be avoided by removing your CSS rule:
.rslides li { left: 0; top: 0; }
Specifying width and height is fine, but as soon as you specify left and top - then switch from relative to absolute positioning, you get that jump you're seeing.
As for the positioning of each panel - it has to do with the way you are laying out your boxes. The sizes you are specifying are not large enough for the content you are providing. For instance: <div id="header"> is 37px tall, which is the appropriate size for the social media buttons, but you also have it as the container for the #nav-menu UL - which is another 102px tall.
It appears that in order to correct this and make things overlap, you are using negative margins - which is getting you all thrown off.
My suggestion would be to use a standardized layout system, such as any of the following:
http://cssgrid.net/
http://960.gs/
http://www.1kbgrid.com/
http://foundation.zurb.com/docs/grid.php
And use it to perform your layout tasks, rather than trying to self-craft overlapping layers with mixed absolute/relative positioning.
Alternatively, if you're going to go the overlapping layers route (again, not suggested), really commit to it. Position things absolutely throughout the layout.
In order to accomplish this, you might consider CSS rules like:
#header {
display: block;
position: absolute;
left: 50%; top: 0px;
height: 139px; /* Your Social media links height + nav buttons height */
width: 1018px; /* Your current width */
margin-left: -509px; /* Half the width - centers on page */
}
Again - this is MUCH more work, MUCH harder to maintain and MUCH less elegant - but will yield you at least a consistent spacing / sizing.

Categories