Before anything else, consider giving this a shot. Since you're unsure about the distance between the sticky element and viewport boundary, try adding this to your CSS rules:
element {
overflow: hidden;
position: sticky;
top: 0; // this eliminates the gap
}
Alternatively, you can explore this approach. It's possible that there is extra space due to dynamic width or defined padding
, margin
, etc. If you had provided a code snippet, it would have been more helpful, but I've styled it in the following manner. Using flex-root
for display has also proven to be effective. Give this a go if the previous method doesn't work.
// Experiment with CSS properties:
element {
word-break: break-word;
}
// Eliminate white space caused by padding:
element {
width: auto;
padding: 0;
word-break: break-word;
}
// Another option to try
element {
display: flex-root;
}
// Check out the display flex guidelines:
// https://developer.mozilla.org/en-US/docs/Web/CSS/display
// This property generates a block formatting root element, defining the context where the formatting begins