Changing the viewport zoom level with CSS according to different media queries

Looking to make my website compatible across various screen resolutions, I turned to media queries to adjust the zoom level based on different screen sizes like this:

@media screen and (max-width: 1366px) {
  html {
    -moz-transform: scale(0.75, 0.75);
    zoom: 0.75;
    zoom: 75%;
  }
}
@media screen and (max-width: 1024px) {
  html {
    -moz-transform: scale(0.75, 0.75);
    zoom: 0.75;
    zoom: 75%;
  }
}

The outcomes were as follows:

1. 10920x1080 resolution (No zoom applied, original intended scale) https://i.sstatic.net/YMcvn.png

2. 1366x768 resolution (No zoom or media queries) https://i.sstatic.net/GeMvY.png

3. 1366x768 resolution (Media queries with 75% zoom applied) https://i.sstatic.net/3KMhu.png

While the desired scaling was achieved using media queries and zoom, the issue arises with the viewport not adjusting accordingly and remaining at its original level (as seen in image 3 with white space outside of the viewport). Adjusting the window zoom with Ctrl + does align the viewport properly.

Any suggestions on how to resolve this problem?

Answer №1

To achieve a responsive design where the screen scales according to device width and zooms out to 75%, consider using the viewport meta tag:

<meta name="viewport" content="width=device-width, initial-scale=0.75">


Media queries should be used for resizing content independently for various viewport widths rather than uniformly scaling content based on screen widths. In this scenario,

@media screen and (max-width: 1366px)
already encompasses
@media screen and (max-width: 1024px)
.

However, if there is a second declaration for

@media screen and (max-width: 1024px)
, screens below 1024px width will apply that declaration over
@media screen and (max-width: 1366px)
.

In this case, having identical declarations for both media queries renders them repetitive.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to adjust the time font size according to the dimensions of the time picker?

HTML and CSS .pickthetime { height: calc(var(--vh, 1vh) * 3); width: calc(var(--vw, 1vw) * 25); align-content: center; // center looks better, also tried left to stop it from breaking a new line on Safari on iOS font-weight: 300; } <input cla ...

Refreshing GIF images in React using forceReload

In order to restart the gif animation every 12 seconds or whenever the activeIndex changes, I need to reload a GIF image with CHECKMARK_ANIMATION_ICON as the source. Below is the code: const reloadImgSource = (imgSource) => { setTimeout(() =& ...

Vue fails to update a component's appearance even after changes have been made to its data

Hey guys, I'm having a little trouble with one of my Vue components. My goal is to have an image displayed by default, and then change to another image when clicked, triggering a different action. <b-img v-else-if="isopen = true" fluid s ...

Tips for implementing an HTML modal with AngularJS binding for a pop up effect

As a beginner in AngularJS, I am facing a challenge. I have an HTML page that I want to display as a pop-up in another HTML page (both pages have content loaded from controllers). Using the router works fine for moving between pages, but now I want the s ...

Is there a way to verify that input is not empty upon loading?

Here is some code I am working with: <div><input type="text" value=""></div> Could someone please help me figure out how to use JS or jQuery to check if the input has any data (including local storage or browser cache) on load, and then ...

Steps to assign a value to an input element using the state in a React application

Hey there, I hope everything is going well for you! I have a question regarding setting the value of an input field based on the state received from props. I've tried to populate the input with data from the "profile" state using placeholders, but it ...

The collapsed feature of the Bootstrap 4 Navbar is not functioning as

Recently, I delved into the world of Bootstrap 4 and decided to create a collapsing menu. Everything seemed to be working fine when I clicked the button and saw the content display perfectly. However, things took a turn for the worse when I tried to collap ...

Creating a continuous loop animation with CSS hover state

This piece of code creates an interesting effect when the text is hovered over. The slight shakiness adds a cool touch to it. However, this effect only occurs when the mouse is moved slowly; if the mouse remains stationary, the hover style takes precedence ...

Tips for crafting paragraphs that double as sieves

I'm trying to simplify and shorten this code. I have three HTML paragraphs acting as filters: "all", "positive," and "negative", referring to reviews. Each has a corresponding div for reviews: "allcont", "poscont", and "negcont". Clicking on any of th ...

How can I determine the remaining amount of scroll left in my HTML document?

Is there a method to determine how many pixels of scroll remain on the page when the scrollbar is set at a specific position? I am currently utilizing jQuery's scrollLeft feature, which can be found here: http://api.jquery.com/scrollLeft/. I want to ...

Establish the directory for javascript and css files following the designated URL rewriting regulations in the .htaccess file

Currently in the process of rewriting my URLs by configuring rules in the .htaccess file. The current version of my .htaccess file looks like this: Options +FollowSymlinks RewriteEngine on AddType text/css .css RewriteRule ^lunettes-collection/([ ...

What are the specifications for the opacity, width, and height of the background image in Bootstrap's

My current project has specific requirements that I need assistance with: I need the background image of the jumbotron to fit the width of the page and have its height scaled proportionally. The opacity of the jumbotron's background image should be ...

Issues with responsive CSS on mobile devices

I am experiencing an issue with responsiveness on my website - there is too much empty space between the element and the end of the window when viewed on a mobile phone. I have added the following code to my document in the head section: <meta name="vi ...

The lengthy email exceeds its limits

https://i.sstatic.net/juD2P.png https://i.sstatic.net/WQo8o.png Take a look at this code snippet: <div className='mt-[3vh] flex h-1/3 min-h-fit w-[80%] min-w-[300px] flex-col content-center items-center justify-center rounded-2xl bg-white shadow ...

Is it possible to have text links styled, but without any actual hyperlinking?

Today has been rough, and I'm struggling to find a solution to my problem. Here's the issue: I have some nice CSS for links, but I only want it to apply to text links, not images or divs. Just plain text. My current code looks like this: a { ...

Creating a left, down, left line drawing animation using only CSS

Utilizing CSS transitions to animate a line drawing from right to left, then down, and finally continuing to load to the left: point 1------point 2 | | | ---------point 3 Here is the CSS code I ...

Responsive images in CSS3/HTML5 are designed to adapt to different

I am looking to implement responsive image sizing based on the webpage size. My images come in two different sizes: <img src="images/img1.jpg" data-big="images/img1.jpg" data-small="images/img1small.jpg" alt=""></img> The data-small image has ...

Ar.js results in objects experiencing deformation or modification when manipulated

Recently, I started experimenting with Ar.js and encountered an issue where the objects displayed on the screen seemed distorted. To illustrate this problem, let me share a basic A-Frame example featuring a perfectly round sphere: <!DOCTYPE> <html ...

Disable the outer div scrolling in VueJS, but re-enable it once the inner div has reached the bottom of

I am currently working on a webpage that contains multiple divs stacked vertically. Here is the concept I am working with: Once the scrollbar reaches the bottom of the first div, the outer scrollbar will be disabled and the inner scrollbar will be enabled ...

Instructions for inserting text into a donut chart created with Google, utilizing basic HTML, JavaScript, or jQuery syntax

Are there any attributes in Google Chart that I should know about? I am just starting to use Google Charts and would appreciate some guidance. Here is the code snippet I am working with: function drawChart() { var data = google.visualization.arrayTo ...