Customize default zoom settings with Cascading Style Sheets (CSS)

body{
  margin-bottom: 10%;
  margin-left: 10%;
  width:80%;
  color: #264653;
  position: relative;
}
#photo{
  border-radius: 70%;
  position: absolute;
  left: 25%;
  top: 50px;
}
.left1{
  margin-top: 10%;
  background-color: #264653;
  width : 30%;
  color: white;
  position: relative;
}
.left2{
  background-color: #264653;
  width : 30%;
  padding-bottom: 20%;
  padding-top: 25%;
  padding-left: 1.5%;
  color:white;
  font-size: 20px;
  text-indent: 12px;
}
#title{
  text-align: center;
  position: absolute;
  left: 31.5%;
  top: 0;
  font-size: 25px;
  border: 1px solid white;
  padding : 20px 175px;
  background-color: white;
  color:#264653;
}
.right{
  position: absolute;
  left:35%;
  top : 30%;
  font-size: 20px;
  font-weight: bold;
  width: 60%;
}
.article{
  display: block;
  background-color: #264653;
  text-transform: lowercase;
  font-variant: small-caps;
  padding-left: 20px;
  font-size: 100%;
  margin-right: 20%;
  width: 90%;
}

.annee{
  display: inline-block;
  width: 15%;
  font-weight: bold;

}

Upon excessive zooming, the webpage can lose its original design with images and text appearing mashed up together.

To maintain the original design even when zoomed in excessively, what steps can be taken?

Note: Included is the provided code, seeking clarification on potential issues like the use of "position".

Answer №1

Consider implementing a Responsive Design for your website

https://i.stack.imgur.com/uJIgQ.png

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<h2>Responsive Image</h2>
<p>By setting the CSS width property as a percentage, images can scale based on browser window size. Test by resizing the window.</p>

<img src="img_girl.jpg" style="width:100%;">

</body>
</html>

Answer №2

It seems like you haven't shared any code related to your design, making your question quite broad as it relies heavily on the layout and styles you have implemented. Below is a sample code snippet along with some tips that may assist you in resolving your issue:

*, *::after, *::before {
    padding: 0;
    margin: 0;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

.container {
    width: 1000px;
    background-color: #4b8ff0;
    color: white;
    margin: 20px auto;
}

.container::after {
    content: "";
    display: table;
    clear: both
}

.leftTag {
    float: left;
    width: 25%;
    height: 360px;
    background-color: #7f000a;
}

.rightTag {
    float: right;
    width: 70%;
    height: 360px;
    background-color: #123456;
}

@media only screen and (max-width: 854px) {
    .container {
        width: 750px;
    }
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <title>zoom-file</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
   <div class="container">
       <div class="leftTag">
           <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolor similique vel ex, quis sint at accusamus labore sit.</p>
       </div>
       
       <div class="rightTag">
           <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Officiis reiciendis fuga veritatis quaerat praesentium ipsa saepe commodi placeat atque provident vitae illum molestiae, adipisci repudiandae nesciunt ducimus sit ipsam ea quibusdam architecto ut qui beatae! Numquam vel mollitia, expedita iure est. Est voluptatibus, minima obcaecati accusamus, libero aperiam fugiat, repellat a hic deleniti quia maxime.</p>
       </div>
   </div>
    
</body>
</html>

The provided example showcases a simple container with two columns placed side by side using the "float" property. When zooming in, you will notice that the width of the ".container" changes to 750px due to the "@media" rule in CSS. You can learn more about it here.

Additional helpful links include resources on JavaScript's "resize" method and window width:
https://www.w3schools.com/jsref/event_onresize.asp
https://www.w3schools.com/jsref/prop_win_innerheight.asp

Lastly, consider utilizing relative units (e.g., width:45%) to establish relative sizes for tags compared to their parent elements. This approach minimizes adjustments needed for varying window sizes since browser window width changes when zooming in or out.

Answer №3

Hello @issou! To address your issue, it is recommended to convert all PX units to REM in order to ensure responsiveness. When setting values in PX, they remain fixed regardless of zoom level. However, using REM ensures that the size adjusts with the zoom level.

By default, 1rem equals 16px. You can also establish this conversion in the ::root element of your HTML page. 

I hope this explanation is helpful. If you need further clarification or have more questions, feel free to reach out!

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

Identify and forward to the mobile-friendly version of the site

I am currently working on a website that requires separate files for mobile view as the html layout poses challenges in making it responsive. My goal is to find code that can detect if the user is accessing the site from a mobile device, and automatically ...

Horizontal compression applied to background image

After following a suggestion ("css only technique number 1" found here http://css-tricks.com/perfect-full-page-background-image/), I experimented with using an inline img element and CSS to create a background image that would occupy the entire browser win ...

- Customizing the width of each dropdown level in a unique way

Working on a customized menu design that you can view live at: Focusing on the third level menu, I encountered an issue where all menus have the same width due to sharing the dropdown-menu class. While I understand the root cause of the problem, I am unsu ...

Show XML data with namespaces - utilizing PHP

Can someone help me figure out how to display values from an API that returns XML? I've been searching, but most examples don't have namespaces or handle both. When I try with both, it always causes bugs and fails to display the values... Here i ...

Beautiful ExpressionChangedAfterItHasBeenCheckedError

I need your help Input field where I can enter a Student email or IAM, which will be added to a string array List displaying all the students I have added, using a for loop as shown below Delete button to remove a student from the array The list has a sp ...

Tips for displaying only a list of folders in elfinder, a jquery file management plugin

Currently, I am working on enhancing the features of a file manager plugin that allows users to manage their folders effectively. One key functionality of the plugin is the ability for users to share specific folders with others. However, if a folder has n ...

Incorporate a Background Image, which is linked to a website URL, by utilizing an external CSS file within

I am struggling to incorporate an external CSS file (specifically a background image from a URL) into my HTML document. I have successfully applied internal CSS, so the issue is not with the website link. Despite reviewing similar posts addressing comparab ...

Struggling to make a basic ajax request function correctly

I've been experimenting with this code snippet in my browser's console. $.ajax({ type: 'GET', url: 'http://stackoverflow.com/', dataType: 'html', success: function() { console.log("Yes, t ...

Updating inner text content dynamically can be accomplished without relying on the use of the eval() function

I am faced with a situation where I have multiple batches of code structured like this: 1 <div id="backgrounds" class="centery">Backgrounds 2 <div id="bk1" class="attr">Background 1 3 <div class="container"> 4 ...

In the case of a PDF being in landscape orientation, the full width of the document is not utilized despite the width being set to

Even though I have specified the width of the Header table to be 100% and applied a margin-right of 1cm for PDF reports with landscape orientation, the table is not taking up the full width. However, when my PDF report has portrait orientation, the header ...

Original text: Default SVG styleRewritten text

Could you please provide information on the default style of SVG? For instance, what is the default font used in a new SVG document? Is this specified in the SVG specifications? <svg><text x="10" y="10">Hello</text></svg> Thank yo ...

Is it permissible to have <ul> tags within an H1 element?

I am curious about whether adding a list inside an H1 heading could cause any issues: <h1> <ul> <li><a href="...">some link</a></li> <li><a href="...">another link</a></li> <li>curre ...

Obtain the href attribute's value from an HTML document using Javascript

I'm facing an issue here. Currently, I am utilizing Grid.js (http://tympanus.net/codrops/2013/03/19/thumbnail-grid-with-expanding-preview/) for my project. Now, my goal is to incorporate a Lightbox with multiple thumbnails inside the dropout provide ...

The positioning of sub-menu items is incorrect

I would like the subitems in the menu to be positioned directly under the main menu items instead of being slightly offset to the right. CSS ul#menu { float:left; width:100%; margin:0; padding:0; list-style-type:none; background-c ...

What is the best way to transfer a JavaScript variable through a query string from one HTML page to another?

Is there a way to pass a JavaScript variable called username from one HTML page, example1.html, to another HTML page, example2.html, using query strings? <script type="text/javascript" > $(document).ready(function() { $('#SubmitForm ...

Manage the placement of elements using CSS

Having an issue here. The blue-colored elements are showing up vertically, but I want them to be displayed horizontally. I've tried various methods but haven't been able to solve the problem. Providing just the code for the items below due to len ...

Date Selector Tool for Input Field

Does anyone know how to change the color of the date picker that appears in certain browsers but is unsure about the selector's name? HTML: <form action="pledge.html" method="post"> <input type="date" id="birthday" name="user_bda ...

Utilize UI Kit to incorporate fluid margins dynamically

How can I dynamically add internal margins between cards in a responsive layout? The following code ensures responsiveness: Large Screens display 4 Cards. Medium Screens display 3 Cards. Small Screens display 2 Cards. Micro Screens display 1 Card. &l ...

Is the use of div:after content really affecting the width? I am having trouble getting my transition to work

Here is a simple code snippet that represents my actual code: #myDiv { background: black; color:white; float:left; min-width:45px; max-width:450px; -webkit-transition: all 1s ease-in-out; transition: all 1s ease-in-out; } #myDiv:hover:after { width ...

The HTML page won't stop refreshing

I am having trouble with my admin login page code. Instead of redirecting, the page keeps refreshing. I have searched through numerous articles but have been unable to find a solution. Here is the code: <!DOCTYPE HTML> <HTML> <head> ...