When creating fixed navigation bar with padding, we got :
1 | position: fixed; |
However you will find padding-right disappear, the reason is the width is window width + padding-left + padding-right
. It is exceed the window, to fix it just use width: calc(100% - 30px)
to reduce the width
1 | position: fixed; |
See the Pen Fixed nav with correct padding by AsinChen (@Asing1001) on CodePen.