Adjust the proportions of the entire body while changing the window size

I have a unique vision for a website that defies the norm of responsiveness. When resizing the windows, I want everything to scale up or down while maintaining the same ratio. Even if the text becomes too small on smaller screens, my main goal is to prevent any elements from overlapping during resizing.

I've experimented with different approaches:

<meta id="meta" name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">

As well as this JavaScript code:

<script type="text/javascript">
  $(document).ready(function () {

    $(window).resize(function () {
      calculateNewScale();
    });

    calculateNewScale(); // adjust for window size less than 1920px

    function calculateNewScale() {
      var percentageOn1 = $(window).width() / 1920);
      $("body").css({
        "-moz-transform": "scale(" + percentageOn1 + ")",
        "-webkit-transform": "scale(" + percentageOn1 + ")",
        "transform": "scale(" + percentageOn1 + ")"
      });
    }
  });

And I've also dabbled with CSS:

body {
width:100vw;
height:100vh;
}

You can find the current version of the website here:

kotechweb.com/new_focus/page/about_us

However, an issue persists where the content overlaps when the window is resized. My quest continues to find a solution to this challenge.

Answer №2

<meta id="meta" name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
This code snippet functions properly only when the window is loaded and not resized

The calculateNewScale() function attempts to resize the body element Consider changing your font sizes from px to % or rem units

Although you may prefer a non-responsive site, utilizing CSS media queries can still assist in achieving your desired layout.

Answer №3

When crafting a response, consider the following guidelines:

1. The "width=device-width" parameter adjusts the page width to match the device screen width. 2. Setting "initial-scale=1.0" determines the initial zoom level on page load. For example:

Additional rules to keep in mind: 1. Avoid using large fixed width elements 2. Ensure the content is not dependent on specific viewport widths for proper rendering 3. Utilize CSS media queries to customize styles for different screen sizes

In addition, leverage the media property to apply CSS styles tailored to different screen sizes.

Answer №4

Here are some steps you can take to improve your website layout: 1. Revise your HTML structure by placing image, content, and footer components within a container or wrapper element like

<html>
  <head></head>
  <body>
    <div id="wrapper">
      //all elements inside this wrapper
    </div>
  </body>
</html>
  1. Consider using rem/em units instead of px for consistent sizing. Inconsistently using different units may lead to layout issues such as word shifts.

  2. If you are utilizing Bootstrap in your project, make sure to leverage the BootStrap Grid system for better responsiveness. Start by designing for mobile devices first, then adjust for larger screens accordingly.

Wishing you success with your website improvements!

Answer №5

To utilize bootstrap effectively, consider switching the container class to "container-fluid"

Answer №6

The viewport tag you are using is incorrect. It should be

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">

Alternatively, try using

<meta name="viewport" content="user-scalable=no" />
instead.

Answer №7

When utilizing pure transform: scale(x), various challenges such as margin, centering, and positioning issues may arise unless complemented with JavaScript logic.

Here are some CSS solutions:

1) Adjust the background scaling based on browser width by adding

body { 
  background-size: cover;
  background-repeat: no-repeat;
}

2) Use vw units for all measurement units, as demonstrated in this example:

Font scaling based on width of container

For instance, to make fonts scale proportionally to the width, you can set

body {
  font-size: 0.835vw; //approximately 14px at 1920px
}

Another scenario is if you want a container that is 300px tall at 1920px width to adjust based on width, you can define the container like this

.container {
  height: 150vw; //around 300px at 1920px
}

If you aren't aiming to keep the footer fixed at the bottom under all circumstances, you can utilize position:fixed; for the footer.

It's worth considering that maintaining a fixed aspect ratio could lead to unusual spacing when the browser height exceeds the width. Is this the desired outcome?

Remember, resizing content in this manner is unconventional and may result in performance and readability issues (as you are already aware). It's generally recommended to use meta tags for devices or implement responsive design elements.

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

Creating a JSON array using looping technique

I am attempting to construct a JSON array using a loop where the input className and value will serve as the JSON obj and key. However, I am facing difficulties in creating one and cannot seem to locate any resources on how to do so. Below is an example sn ...

Troubles arise with java.io.PrintWriter when attempting to print multiple spaces on the web browser

In the file named test.txt, I have a list of Names as content. For example, let's take "Sachin    Tendulkar" where there are four spaces between the first and last name. My servlet is responsible for reading this text file and disp ...

Implementing Angular's ngModel directive within an conditional statement

As a newcomer to Angular, I am attempting to write code that will display a list of checkboxes. My goal is to only show checked checkboxes in the list and not display unchecked ones. I am using ngModel to retrieve data from an interface. I attempted to use ...

Extracting IDs, classes, and elements from a DOM node and converting it into a string format

Can someone please guide me on how to extract the DOM tree string from an element? Let's consider this HTML structure: <div> <ul id="unordered"> <li class="list item">Some Content</li> </u ...

"Enhancing security measures with multiple nonce for Content Security Policy

I am encountering an issue with my single page application, which is developed in .net core MVC 2.2. The application loads html sections on the fly. In the main document, I have added a Content Security Policy (CSP) policy with a dynamically generated hea ...

Experiencing issues with receiving an 'undefined' response when using the jquery find

Looking at my HTML page structure, here is how I have set up an event for input.global_filter using jQuery: $('input.global_filter').on('keyup click', function() { document.write($(this).find('.example:first').prop(' ...

Eliminate the use of 'sip:' when dialing the number

I am currently using the softphone eyebeam to make calls. Whenever I click on a SIP link like this: <a href="sip:0123456789">0123456789</a> The issue arises when eyeBeam adds the "sip:" prefix before the number, causing it not to recogniz ...

Issues with Bootstrap Navbar not appearing after deployment on Heroku (NodeJS, Angular2)

Before anyone considers marking this question as a duplicate, this specific inquiry on Stack Overflow offers a solution involving Ruby and Rake, which unfortunately does not apply to my current situation. I am puzzled as to why my bootstrap nav bar is mys ...

Combining the background images of two separate <div> elements results in a deeper shadow effect than when they are individually displayed

Encountering an issue with overlapping background images that results in a darker shadow where they intersect, causing an uneven appearance. The problem arises with a flexible height box containing semi-transparent background images designed to create att ...

Modifying the alignment of Angular elements within the router-module to complement an established CSS grid

I'm facing an issue with my angular reactive-form project. I have successfully set up everything except routing. After defining all the routes in the app.module.ts file, things started getting messy. In my basic form, I had a responsive CSS grid with ...

Is there a glitch or a misinterpretation of the specifications concerning the use of relative padding

VIEW DEMO At times, I like to create a square (or any rectangle) that maintains its ratio regardless of size, using a technique similar to this method. My Objective: To prevent the square from extending beyond the viewport on devices with limited heigh ...

Issue with AngularJS bug in Internet Explorer when using regular style attribute compared to ng-style

While working with Angular JS v1.1.5, I came across an interesting issue related to Internet Explorer. In IE 9, 10, 11, and Edge, the following code snippet doesn't work as expected, even though it works fine in Chrome: <div style="width: {{progr ...

The submit button is not lining up properly with the input field

I've encountered an issue while creating a search bar with a submit button. When I link the input box to a class in my CSS document, it causes misalignment between the box and the button. Here's a visual representation of the problem: Current Al ...

Display information using HTML elements within a loop in JavaScript

I am facing an issue with iterating over an array of objects in JavaScript. Each object contains multiple parameters, and my goal is to extract the data from each object and display it in a table or a grid format. Here is an example of my code: function ...

"Enhance your shinydashboard with a customizable header dropdown feature that allows you

I am trying to create a vertical grouped dropdown menu in the header panel that contains multiple links. Currently, I can only achieve a flat horizontal layout using tags$li. I want to place linkA and linkB under grouplinkAB, allowing users to open one o ...

Working condition may vary depending on the size of the item

I have integrated the Masonry jQuery plugin into my design, but it is not functioning properly. The CSS class mentioned in the documentation only includes: width: 25% For my purposes, I modified it to: width: 24% float: left margin-right: 5px This modi ...

JavaScript is causing a performance problem when attempting to hide the header while scrolling

In my attempt to create a navigation bar, I have specific requirements: It should start with a large height Disappear when scrolled down Show a smaller version when scrolling back up Expand to full height when fully scrolled to the top I have managed to ...

Personalize Progress Bar with Bootstrap 4

I am working in Bootstrap 4 alpha and I'm having trouble customizing certain elements like the border-radius, bar base color, and filled color. Can anyone help me figure this out? I've tried to manipulate the code below, but unfortunately, it&ap ...

Utilizing a Nested For Loop in Jinja for a Flask-based Web Application

Currently, I am in the process of developing a straightforward social networking web application. On the feed page, my goal is to display all posts with the names of the users who uploaded them along with their corresponding feedback. My main issue lies i ...

It seems like the Overflow Hidden feature is not functioning as intended

I'm facing an issue with the overflow:hidden; property not working as expected. My goal is to have multiple inline elements inside a div be cut off at 20 pixels using overflow: hidden; Here's the code snippet: <div class="container"> ...