javascript - How do I take the scrollbar into account with viewport width units? -


i trying develop carousel similar netflix, cannot make responsive. have been using codepen example:

link example

in example, has hardcoded width , height. make use responsive measure (percentages). wanted use vw viewport width units, doesn't work me because not exclude scrollbar. so, when want every carousel item have width of 20vw (so each 1 20% of viewport size), wider want because viewport not exclude scrollbar.

how can fix problem?

i have made example: link

in example, want show 5 items , showing arrow on right. 6th item should hidden behind arrow, arrow width not correct.

the width of every item 18.4vw ( (100-8)/5=18.4). can see, have put padding on left , right 4vw(so, subtracting 8 total width), so, have made arrow layer with:

position:absolute; right:0; width:4vw; 

in manner, arrow fixed right.

the problem 18.4vw measure respect viewport, , there scrollbar, width not correct, because scrollbar width breaking correct measure.

i dont know if understand want make.

br.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -