As I adjust the size of my browser window, my images automatically resize to properly fit within it. However, when I zoom in or out, the images remain at a consistent

What is the solution to this issue? My images are set to percentages, but setting a height percentage does not seem to have any effect.

The relevant HTML code snippet:

<div class="header">
   <img src="pictures/header.png" width="30%">
   </div>

CSS for the "header" div:

.header {
margin: auto;
width: 70%;
padding: 1%;
text-align: center;
font-family: Arial, Helvetica, sans-serif,"serif";
font-size: 130%;
color: #e5e5e5;
background-color: #232323;

HTML for the second image section:

<div class="main">
<h1> bla bla bla </h1>
<img class="right" src="bilder/wave.gif">
<p> bla bla bla </p>
</div>

CSS for both classes mentioned (.right and .main):

.right{
    float: right;
    width: 15%;     
}

.main{ 
margin:auto;
width: 70%;
padding:1%;
align: center;
text-align:left; 
font-family: Arial, Helvetica, sans-serif,"serif";
color: #2b2b2b;
font-size: 130%;
background-color:rgba(178, 92, 42, 0.5);
background-image: url("../pictures/scroll.jpg");
background-size: 100%;
padding-bottom:2%;
}

Answer №1

Zooming in does not change the height or width of the window, so percentage units operate based on that unchanged size.

Browsers only support zoom for text as they use pixel units for font sizes.

For a demonstration, set a fixed width using pixels and then zoom in to see the element grow and shrink accordingly.

Answer №2

If you are looking to tackle the issue of browser zooming, one effective solution is to employ the CSS property "box-sizing:border-box".

* { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }

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

Store the ID of a div in a variable

Currently, I have transformed rock paper scissors from a terminal/console game using prompts and alerts to something playable in a web browser through the use of the jQuery library. In order to achieve this transition, I created images for each hand - roc ...

Regular expression for capturing multi-line HTML comments using preg_match_all

I am dealing with an HTML document that contains several commented-out PHP arrays, such as: <!-- Array ( [key] => 0 ) --> My goal is to extract the contents of only these specific comments using PHP. I have attempted to achieve this by using pre ...

Move the absolute div by sliding it to the left from 120% to -10px

I want to move an absolute positioned div from the left side of the screen to -10px on button click. Here's my attempt so far, but it's not working as expected. Javascript/jQuery $('.button').click(function() { $(this).parent().f ...

Align the text on the same horizontal line

I have been struggling with this issue for hours. Here is my Header.js <div className="navbar-inner"> <h2>Text1</h2> <h3>Text2</h3> </div> This is the content of my Header.css: .navbar-inner { ...

What is causing this PyScript code to malfunction?

While working on a school project to create a PyScript calculator program, I encountered a situation where the script stopped functioning correctly. Strangely, I had to resort to using the alpha version of PyScript in order to make a functional calculator. ...

Having trouble with my Angular application, seems to be stuck at the loading screen. Not sure what's causing it, possibly

Hey there, I'm hoping to create a straightforward app that showcases posts. However, I've encountered an issue when deploying the initial page which is stuck on "Loading...". I believe it's a minor problem and would appreciate your assistan ...

What is the best way to eliminate leading zeros in PHP when echoing SQL statements?

Being a front-end programmer on a team of three, my PHP/MySQL skills are fairly basic. However, our back-end programmer is going on vacation and we have a deadline to address a minor visual detail. Currently, we are working on a page that displays multiple ...

Ways to identify whether a div is in view and includes an input field

This is a unique question that is not related to the issue of querySelectorAll detecting value in input. Instead of asking whether an input field has a value, I am interested in how to detect if the current visible div contains an input field. This is a n ...

Forwarding to another servlet based on the action of an HTML page

There are 2 servlets included in my code snippet @WebServlet("/Login") public class Login extends HttpServlet { ......... ......... } @WebServlet("/Create") public class Create extends HttpServlet { ......... ......... } Accompanied by an HTML page ...

What are some solutions for resolving the problem with the anchor attribute in Safari?

There is a problem with the anchor tag used in my website. The number 619-618-1660 is being displayed when I view the site on Safari browser or an iPhone, even though it is written as (href="tel:619-618-1660"). See the image at the link below for reference ...

Encountering a 422 Unprocessable Entity error when the search bar in the frontend is empty - What is the best way to handle

My frontend setup includes a search bar with an input field By combining HTMX and FastAPI, I am able to dynamically fetch user information from a static list of dictionaries. I aim for dynamic results that update as I type, and the fetching of user infor ...

Tips for creating a Carousel with more than three images using Bootstrap

Recently, I attempted to enhance my Carousel in Bootstrap by adding more images. Initially, I inserted the code snippet below within the ordered list with the class "carousel-indicators." <li data-target="#carouselExampleCaptions" data-slide-to=" ...

Conceal any zero values from an empty numerical input

Currently, I have a form that retrieves data from a database and includes a number input type field. When the field is empty, it defaults to displaying "0." However, I would like to hide the "0" and only show the value if it is different from 0. Despite a ...

Navigating a table list in React using arrow keys without inadvertently scrolling the scrollbar

Currently, I've created a table component that contains a list of items. I've implemented hotkeys using the react-hotkeys package to allow users to navigate through the list using the 'arrow up' and 'arrow down' keys. The issu ...

The function .click does not function properly when used with an anchor element within a figure tag

In my JavaScript-loaded figure, there is an image description and two buttons. Sometimes the description contains a link with a fig attribute, like this: <a fig="allow" href="#tt5">[1]</a> If the anchor is not in a figure and has a fig attrib ...

The media query is not properly adjusting for zoom levels

I have been attempting to implement a media query that will cause my website to zoom out (shrink) for devices with a width less than 800px. However, it seems like the query is not having any effect. I placed the query in the head section of my HTML documen ...

Troubleshooting problem with iPhone X responsiveness

Struggling with responsive issues on iPhone X. Issue is only appearing on actual device. Any tips for fixing this? I'm facing an issue where the website looks good and responsive on all devices in Chrome's responsive view. But when I access it th ...

What is the best way to obtain the true dimensions of an HTML element?

Is there a way to determine the dimensions of a <div> element in order to accurately position it at the center of the browser window? Additionally, which browsers are compatible with this method? ...

Attempting to insert an image into an HTML document

Simple question - feeling exhausted trying to uncover the solution. Here is what I am attempting: a(href="https://github.com/xxx") img#github-banner(style="position:absolute;top:0px;right:0;border:0;", src="app\public\img\logo ...

How can we save the final composite image created with image layers, Cufon, jQuery,

I'm currently exploring the possibility of a new idea, but I'm not entirely certain if it can be achieved. My progress so far involves loading an image from a URL and using jQuery UI draggable feature to enable users to drag HTML text (which has ...