Are scroll bars always the same width in different

2019-08-04 02:59发布

I need to make a CSS adjustment to compensate for a scroll bar. So I was wondering- are scroll bars always the same width in different browsers and operating systems?

I have two tables, one above the other, with matching columns widths (set to percentages). One table needs a scroll bar, so I want to add another column in the table above it to compensate for it, so the columns line up.

3条回答
萌系小妹纸
2楼-- · 2019-08-04 03:24

SWEET!Here's a solution for anyone who has this same problem. This should be cross-browser compatible too.

Just add a scroll bar to the top table as well, with some extra CSS to hide them.

#topTable{
    overflow: scroll;
    padding-right: 16px;
    padding-bottom: 16px;
    margin-right: -16px;
    margin-bottom: -16px;
}

In theory, all you have to do is make the "16px's" match, so you can do this with the same effect:

#topTable{
    overflow: scroll;
    padding-right: 100px;
    padding-bottom: 100px;
    margin-right: -100px;
    margin-bottom: -100px;
}
查看更多
放我归山
3楼-- · 2019-08-04 03:33

Scrollbars aren't even counted the same in different browsers, some of them put them inside the frame, while others put them outside (thus making alignment a real pain).

Try to think of a way of presenting the data where it won't matter.

查看更多
Animai°情兽
4楼-- · 2019-08-04 03:37

I need to make a CSS adjustment to compensate for a scroll bar. So I was wondering- are scroll bars always the same width in different browsers and operating systems?

No, and on some systems their width is user configurable.

查看更多
登录 后发表回答