When I click on column on table it show a div with some informations , the div is a little bit long with plus than 400px in height, that why I need to scroll down to see it all , but unfortunately i can’t ,even it exceed the hight of th webpage still nothing happened it like it not even there , the horizontal and vertical scroll bar work fine with table but not with the div .
Here is the html of the div . :
<div className='overlay'>
<div className="container-vertical">
<div className="point-vertical">
<label className='noisy'>Noisy-le -Sec</label>
<button className='button_veri_green'><img className='img_veri_green' src={veri_green}></img></button>
<label className='gps'>93130, France | Type | Statut</label> </div>
<div className="line-vertical"></div>
<div className="point-vertical"><label className='noisy'>Noisy-le -Sec</label> <button className='button_veri_red'><img className='img_veri_green' src={veri_red}></img></button><label className='gps'>93130, France | Type | Statut</label> </div>
<div className="line-vertical"></div>
<div className="point-vertical"><label className='noisy'>Noisy-le -Sec</label> <label className='gps'>93130, France | Type | Statut</label> </div>
<div className="line-vertical"></div>
<div className="point-vertical"><button className='timer_btn'><img className='timer' src={timer}></img></button><label className='noisy'>Noisy-le -Sec</label><button className='x'><img className='img_veri_green' src={x}></img></button> <label className='gps'>93130, France | Type | Statut</label> </div>
<div className="line-vertical"></div>
<div className="point-vertical"><button className='question_mark_btn'><img className='question_mark' src={question_mark}></img></button> <label className='noisy'>Noisy-le -Sec</label> <label className='gps'>93130, France | Type | Statut</label> </div>
<div className="dot-vertical"><img className='img-vertical' src={car_img} /></div>
</div>
</div>
the CSS :
.overlay {
position: fixed;
width: 458px;
height: 422px;
top: 0;
left: 0;
background: #FFFFFF;
overflow-y: auto;
box-shadow: 0px 3px 6px #1F1F1F29;
z-index: 999; /* Set a high z-index value */
}
The js code that show it :
const overlay = document.querySelector('.overlay');
const tdWithProgression = document.querySelectorAll('.progression');
tdWithProgression.forEach(td => {
td.addEventListener('click', (event) => {
event.stopPropagation();
const tr = td.parentElement;
const rowIndex = tr.rowIndex;
const trows = document.querySelectorAll('tr');
trows[rowIndex].style.background = 'white';
// Calculate the position relative to the viewport
const viewportTop = window.scrollY || window.pageYOffset;
const viewportLeft = window.scrollX || window.pageXOffset;
const topset = viewportTop + 200; // Adjust the top position as needed
const leftset = viewportLeft;
overlay.style.display = 'block';
overlay.style.top = topset + 'px';
overlay.style.left = leftset + 'px';
});
});
I tried to add owerflow-y:auto or owerflow:auto , didn’t work , I also tried to make vertical scroll always showed in the page but also didn’t work with the div .
3
Answers
For some reason the problem was in
when I remove it , the position of the div get down but I was able to scroll down to see it , I had just to update the top in the function and it work well, Here is CSS :
and for Javascript I just change this line by adding "-200"
It seems that you’re facing an issue where the content inside the
.overlay
div is not scrolling when its height exceeds the available space. To make sure the content inside the overlay can scroll properly, you should set a fixed height for the.overlay
container and then applyoverflow-y: auto
to enable vertical scrolling when necessary. Here’s how you can adjust your CSS:In this CSS snippet,
max-height
is set to422px
, which is the maximum height you want for your.overlay
container. When the content inside exceeds this height, a vertical scrollbar will appear within the.overlay
container, allowing users to scroll down to view the additional content.Make sure to adjust the
max-height
value as needed to accommodate your content without causing the overlay to extend too far beyond the viewport.