The design became distorted when the fonts were resized in every browser

Looking for assistance with a simple layout issue. When I scale the font in browsers by using CTRL and scrolling up (zooming), the layout does not behave as expected.

I want #allWrapper to scale its dimensions with the body so that the white background extends to the full width. If you zoom in enough and a horizontal scroll bar appears, try scrolling to the right. You'll notice that the allWrapper is smaller than the body, causing the body's color to show instead of white. However, I can't make the whole body white because the footer will also be in this color (not white). Here is the condensed code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
div,body{margin: 0;padding: 0;border: 0;font-size: 100%;font: inherit;vertical-align: baseline;}
body{font-family:Arial,sans-serif;background-color:#066789;}
#allWrapper{background-color:white;}
#header .content {height:90px;background-color:white; position:relative;}
#mainWrapper{margin-top:0.5em; line-height:1.5;}
.center {width:980px;margin:0px auto;}
</style>
</head>
<body>
<div id="allWrapper">
<div id="header">
    <div class="center">
        <div class="content">
        HEADER
        </div>
    </div>
</div>
<div id="content">
    <div id="mainWrapper">
        <div class="center">
            <div class="content">MAIN CONTENT</div>
        </div>
    </div>
</div>
</div>
</body>
</html>

Answer №1

To address the issue, incorporate the following CSS properties into the style of #allWrapper:

min-width:980px;

The root of the problem lies in the fact that the html and body elements expand to 100% of the visible screen, not the entire layout, causing #allWrapper to remain confined within them. This issue persists even when the browser window is resized to a width less than 980px. By specifying a min-width for #allWrapper, it ensures that #allWrapper retains the same width as its content box. Alternatively, you have the option to set the min-width property on the body element instead.

Answer №2

Consider utilizing a percentage instead of precise pixels in this scenario.

For example:

.middle {width:75%;margin:0 auto;}

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

Issue with rendering in sandbox environment versus localhost

Here's a dilemma I'm facing - I have some HTML code on my localhost that looks like this: <div> <p>Go to: <a href="www.foobar.com">here</a></p> </div> On localhost, the output is "Go to: here" with 'he ...

The justify-content: space-between property does not work in a nested flex box scenario

I'm currently working on styling a cart in Angular and facing an issue with aligning the price all the way to the right of the cart. I attempted using `space-between` within the outer div, which worked fine, but when applied to the inner div, it doesn ...

Unable to generate a menu with bootstrap

Hey there, I've been experimenting with creating a responsive menu using Bootstrap, but I'm struggling with the implementation. My vision is to have a logo on the left side and a menu on the right side. Below is the concept for my menu design. ...

How can you determine whether the CSS of a <div> is defined in a class or an id using JavaScript/jQuery?

Hey there, I'm currently working on dynamically changing the CSS of a website. Let's say we have a div like this: <div id="fooid" class="fooclass" ></div> The div has a class "fooclass" and an ID "fooid", and we're getting its ...

What is the best way to make one page disappear and replace it with a pop-up from

I am currently encountering an issue with my sign-in and registration pages. I have a pop-up page that includes both the sign-in and register tabs. When clicking on the register tab, the sign-in page is supposed to disappear and the registration page shoul ...

Guide to linking a label to a checkbox without utilizing the "for=id" method

Below is the code snippet I am currently working with: <li><input type="checkbox" id="checkboxThree" value="Alergia3" ><label for="checkboxThree">Alergia 1</label></li> <li><inp ...

Shading half of the progress bar

I need to fill 50% of the progress bar with a red color. This is my attempt using HTML and CSS: .progress { width:100%; display: inline-block; height: 0.4615384615384615em; padding: 0.0769230769230769em; background: #fff; border: 1px solid # ...

Issues with implementing Dark mode in TailwindCSS with Nuxt.js

After spending a couple of days on this, I'm still struggling to get the dark mode working with Tailwind CSS in Nuxt.js. It seems like there might be an issue with the CSS setup rather than the TypeScript side, especially since I have a toggle that sw ...

Customizing the text color of steps in a v-stepper component using Vuetify.js

When working with the v-stepper component of VuetifyJS, it is easy to change the color of the steps themselves by using the `color` prop. But how can I alter the text of each step? Specifically, I am looking to modify the color of the text that says Name ...

The conditional CSS file does not have precedence over the regular CSS file

Currently, my approach involves using conditional comments to connect to a CSS file named "IEonly.css" if the Internet Explorer version is not greater than 8. My goal is to modify certain properties in the standard CSS file. Oddly enough, IEonly.css effect ...

When hovering over the label area, the entire rectangle will be highlighted

Could someone please assist with highlighting the entire row of the parent for the drop down feature? In the given scenario, level1 and level23 should be highlighted like the child items are. The goal is to highlight the entire row with the entire width. ...

Hiding the SVG element with pattern definitions using the 'display: none' property makes the patterns completely disappear from view

When I include a set of SVG definitions at the top of my body, I encounter an issue where the svg tag with zero height and width creates unnecessary space at the beginning of the document. To resolve this, I initially use display:none, but this leads to pr ...

Tips for adding a click event to a random "div" within a parent "div" element?

Upon clicking a main "Div", it splits into an n X n matrix with random colored divs. I now want to implement a click function for these random colorful divs that are scattered throughout the main "div". $(window).load(function() { var no = 1, $m = ...

Overlap in Bootstrap 4 Sections

I'm facing an issue with two sections on my website. They are properly separated until a certain size, https://i.sstatic.net/e52t2.png, but when the size is reduced, they start to overlap https://i.sstatic.net/aMtHr.png. Below is a snippet of my code: ...

Is it feasible to exclusively apply Twitter Bootstraps .navbar-fix-to-top on mobile devices?

I am working on a website using Twitter Bootstrap 3 and I have implemented the following navbar: <div class="col-xs-12 col-md-10 col-md-offset-1"> <nav class="navbar navbar-inverse" role="navigation"> <div class="navbar-header"> ...

Malfunction detected in JavaScript shopping cart functionality

Trying to implement a functional shopping cart on a webpage has been a challenge for me. I've encountered issues in my JavaScript code that are preventing the cart from working as intended. As a newbie to JavaScript, I'm struggling to pinpoint th ...

Manipulating CSS styles using Jquery only applies to elements with specific id attributes, and not to elements with class attributes

Having some difficulty figuring out a solution to this issue. Attempting to modify certain CSS properties using jQuery. The problem arises when one div has an ID, changing the property there works as expected. However, the other div only possesses a class ...

Switching the vertical alignment of grid items in Material UI when the page is collapsed

When the page is collapsed, the Left grid item element moves to the top of the page and the Right grid element is positioned below it. I would like to reverse this behavior so that the Right element appears on top and the Left element below when the page ...

Enhance a portion of your text with some flair

Is it possible to apply styles to specific parts of text that are within an <input> value or a <span> element? For instance, I have the following data: {text text} an other text... I want to add styles to the text enclosed within {}. Here i ...

The visibility of the Bootstrap modal may vary depending on the version of Bootstrap being used

I am new to web programming and utilized various Twitter Bootstrap templates to build my website. The login page displays Bootstrap modals correctly with the following imports: <link rel="stylesheet" href="css/bootstrap.css" /> <link rel="styles ...