0
Good evening, I know this question has been answered here several times, but none of them worked for me and I will explain why.
In all solutions presented it is necessary to change the parameter position: relative;
for position: fixed;
, but this configuration brings the inconvenience of having to do the manual centralization of Div, specifying its values in px
or another parameter, the width
, that should be width: auto;
, because if you take it out of auto, the Div from the menu bar does not auto-scale according to the resizing of the browser window with the mouse, or the format of the browser window from the user’s pc.
That is why I would like a purely javascript solution for this case, without CSS. Detail, I just want to fix, without any additional effect like animations, etc... Thanks in advance.
It’s a little hard to understand what you’re really trying to do... the
width:100%;
doesn’t solve your problem? Add the code of what you’ve tried, it doesn’t need to be complete, just the menu bar and how you wanted it to stay/adapt.– Chun
Next, I created a fixed-width div menu: 1000px; with automatic centering on the screen through position: auto; With this, whenever I click on the browser border and drag decreasing or increasing the window size, the object adjusts itself and always stays in the center. What I need is to fix it so it doesn’t roll, but if I change the value of position: auto; to position: Fixed; the object is only in the left corner, having to specify manually the position of the div. which prevents that when resizing the window, it will auto-center itself in the browser.
– Vicentte