Remove Redundant Overflow Property: You have both overflow-y: hidden; and overflow: auto; defined for #my-custom-panel. This is contradictory because overflow-y: hidden; tells the browser to hide the vertical scrollbar, while overflow: auto; tells it to show a scrollbar if the content overflows. You should remove or adjust these properties to ensure they are not conflicting.
Enable Vertical Scrolling: If you want the vertical scrollbar to appear when the content overflows, you should use overflow-y: auto; and remove the overflow: auto; line. This explicitly tells the browser to manage vertical overflow by displaying a scrollbar when necessary.
Adjust Container Height: Ensure that the containerâs height (#my-custom-panel) is set in a way that could potentially overflow, considering the viewport size and the content inside it. Since youâve set it to 100vh, which means 100% of the viewport height, ensure that your content is indeed tall enough to require scrolling.
Hereâs how you can adjust the CSS for #my-custom-panel:
Hi @Miguel_Paula Yes, we are happy to help. There are a couple routes you can take moving forward.
You can open up the experience via the chrome inspector (android) or safari technology preview (iphone) and inspect the page to better understand what settings are needed for the scroll bar to work correctly
Secondly, you can implement a scroll bar in a new blank project to verify that no other code could be interfering with your current implementation.
I would take these steps to better understand what your CSS is doing in your project along with referencing the links that Tony shared.
Hello @Miguel_Paula Iâll be happy to share a step by step process of how to create a scroll bar in your project. (make sure you have a z-index: 999; so the UI shows up in front of scene)
To add a UI panel with scroll ability to your A-Frame project, youâll need to create a custom HTML element for the UI and then use CSS to style it, including the scroll behavior. Since A-Frame is built on top of the standard web technologies, you can integrate regular HTML and CSS directly with your A-Frame scene for UI elements that are not part of the 3D scene.
Hereâs how you can achieve this:
Add the UI HTML Structure: Youâll insert an HTML structure for your UI panel directly into your body.html file, outside the <a-scene> tag. This ensures that the UI panel is part of the standard DOM and not rendered as a 3D object within the A-Frame environment.
Style the UI with CSS: Youâll use CSS to style the UI panel, including setting its position on the screen, dimensions, and enabling the scroll bar for overflow content.
Hereâs an example of how you can implement and style the UI panel:
1. Add the UI HTML Structure
Insert the following HTML structure into your body.html file, preferably right after the <a-scene> tag:
htmlCopy code
<div id="ui-panel">
<div class="scrollable-content">
<!-- Your dynamic or static content goes here -->
<p>Item 1</p>
<p>Item 2</p>
<!-- Add more items as needed to demonstrate scrolling -->
</div>
</div>
2. Style the UI with CSS
Add the following CSS rules to your index.css file. This CSS will position the UI panel on the screen, give it a specific size, add a background color for visibility, and enable scrolling for overflow content:
cssCopy code
#ui-panel {
position: absolute; /* Position relative to the browser window */
top: 20px; /* Adjust as needed */
right: 20px; /* Adjust as needed */
width: 200px; /* Adjust width as needed */
height: 300px; /* Adjust height as needed */
background-color: rgba(255, 255, 255, 0.8); /* Semi-transparent white */
border: 1px solid #ddd; /* Light gray border */
overflow-y: auto; /* Enable vertical scrolling */
padding: 10px; /* Padding around content */
box-shadow: 0 2px 4px rgba(0,0,0,0.2); /* Optional: Adds shadow for depth */
z-index: 999; /* Ensures the panel appears above most other elements */
}
.scrollable-content p {
margin-bottom: 10px; /* Adds space between paragraphs */
}
This setup creates a UI panel positioned at the top-right of the viewport (adjust top and right values as needed). The panel is designed to scroll vertically (overflow-y: auto;) if the content exceeds the panelâs height. You can adjust the width and height values to fit your content needs. Iâve attached a photo of this working in an 8th Wall basic project.
Yes, but it doesnât work in my code, I already tested it but it didnât work, can you try this in my code?
My code is a little further behind the conversation.
Hi @Miguel_Paula as I stated I would suggest starting off very simple to better understand what could be the problem. Starting off with all the code it is very difficult to debug.
Some things I see initially is first where are you importing your import './css.css' ? Is this in your app.js file? That is where it should be located not in the body.html.
in your CSS you have display: none; Property : Initially, your panel is set to display: none; , which means it will not be visible. Your JavaScript correctly toggles this to display: block; when the button is clicked. Make sure the button click is actually triggering this event listener. You might want to add a console log to confirm the event is being fired. I would suggest initially keeping it to display: block for debugging purposes.
Potential Typo in HTML Attribute: In the part where you are setting the imagesâ class, there seems to be a typo. For example:
Hello @Miguel_Paula we are happy to help. Please make sure to try the code Iâve supplied in a basic project to better understand how the scroll bar works. This would really help you in your development.
Hi, it took me a while to respond. But I need to push 5 pixels for the scroll bar to appear because I pushed everything to the side. Can you help me push just the scroll bar?