Cómo evitar el escalado de una página web

I am designing a web page that occupies only 80% of the horizontal space. On restoring the browser, the web page scales down automatically which makes it look very cluttered. I want that even on resizing the browser window, the web page does'nt get scaled but just gets scrollable. That is its size remains the same and it can be scrolled.

preguntado el 10 de marzo de 12 a las 11:03

can you show the code/website/screenshot etc so we can see the problem. -

2 Respuestas

If you want a fixed width you need to set a width if you didn't already.

body { width: 900px; }

could do it, unless there are more styles which override it.

respondido 10 mar '12, 12:03

hey, maybe you have'nt understood the question. i have huge stylesheets attached to the webpage for defining the width etc. but if a user scales his browser, the web page scales which i want to avoid. if u scale down your browser and open google or facebook, the web page does'nt scale down, but you have to scroll to view all the contents of google/facebook! thats what I am hoping to do. - Yash Upadhyay

@YashUpadhyay Do you mean using the browser-specific zoom functionality (Like Ctrl++ and Ctrl+- in Firefox) or simply resizing the window? - Simón Lindgren

@YashUpadhyay And Google doesn't use a completetly fixed width either. - Simón Lindgren

@YashUpadhyay This makes for a completely different question than what you posted originally. You should edit your question. - Señor lister

If you want to prevent the user from scaling the page by pressing Ctrl +, Ctrl - or Ctrl Mousewheel, maybe the following piece of code can work for you:

document.body.addEventListener("keydown", (event) => {
    if (event.ctrlKey) { event.preventDefault() }

This will prevent the user from using the Ctrl key, so any functionality related to that would be lost.

Respondido el 18 de junio de 18 a las 21:06

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.