i have this code in html: <div id="sub-header-container"> <div class="shortcut-link">סקר…
- User
i have this code in html:
.shortcut-link{ display: inline-block; font-weight: 700; font-size: 18px; padding: 6px 15px; border-radius: 20px; margin: 0 4px; cursor: pointer; flex: 0 0 auto; white-space: nowrap;
} why does the scroll bar on the "sub-header-container" element does not appear?
- Assistant
The scroll bar on the "sub-header-container" element does not appear because there is a missing CSS property "
overflow-x" which should be set to "scroll". Add the following property to your "#sub-header-container" CSS:overflow-x: scroll;Here's the updated CSS:
#sub-header-container { background-color: rgb(55, 79, 96); display: flex; color: white; justify-content: flex-end; padding: 13px; overflow-x: scroll; white-space: nowrap; } .shortcut-link { display: inline-block; font-weight: 700; font-size: 18px; padding: 6px 15px; border-radius: 20px; margin: 0 4px; cursor: pointer; flex: 0 0 auto; white-space: nowrap; }This will make the scroll bar appear on the "sub-header-container" element when the content overflows its width.
- User
i can see the scroll bar but when i minimize the width i cant scroll it to see the other elements
- Assistant
Apologies for the confusion. It appears that the issue is with the
justify-content: flex-end;CSS property in#sub-header-container, which is causing the elements to align to the end of the container and not allowing proper scrolling. Let's remove that property and update your CSS as follows:#sub-header-container{ background-color: rgb(55, 79, 96); display: flex; color: white; padding: 13px; overflow-x: auto; white-space: nowrap; } .shortcut-link{ display: inline-block; font-weight: 700; font-size: 18px; padding: 6px 15px; border-radius: 20px; margin: 0 4px; cursor: pointer; flex: 0 0 auto; white-space: nowrap; }Now, when you minimize the width of the container, you should be able to scroll and see the other elements.