Zoom in to see the header spanning the entire width of the page

http://jsfiddle.net/CPSKa/

Whenever I zoom in on the header of my website, the line underneath it starts to shrink. Is there a way to prevent this from happening?

Here is the HTML Code:

<div id="main_header">   
 <div id="main_header_wrapper">
     <a href="index.php"><img src="http://chattrd.com/maint/images/logo.png" alt="Chattrd"/></a>

 <nav id="navigation">
 <a href="index.php" class="nav_icon">Home</a>
 <a href="#" class="nav_icon">Blog</a>
 <a href="login.php" class="nav_icon">Login</a>
 <a href="#" class="nav_icon">Sign up</a>
 </nav>

 </div;
 </div;

And here is the CSS Code:

body {
 padding: 0;
 margin: 0;
}
#main_header{
background:#FFF;
padding:10px 0; 
margin:auto;
border-bottom:1px solid #c5c5c5;}

#main_header_wrapper{
width:900px;
margin:auto;}

nav#navigation{
font-family: Arial;
padding-top: 2px;
text-align: right;
font-weight: bold;
float: right;
display: inline;}

a.nav_icon{
color:#000;
-webkit-transition:background 0.2s ease-in;  
-moz-transition:background 0.2s ease-in;  
-o-transition:background 0.2s ease-in;  
transition:background 0.2s ease-in; 
padding: 14px 25px;
text-decoration: none;}

a.nav_icon:hover{
background: #990033;
color: #FFF;}

Answer №1

This code is effective:

#main_header{
width:900px;
}

Answer №2

To resolve the issue, you can update the CSS for #main_header_wrapper as shown below:

#main_header_wrapper {
  max-width: 900px;
  margin: auto; }

The previous fixed width of 900px was causing alignment problems when zooming in beyond the viewport width. Using max-width instead helps maintain proper alignment.

Answer №3

Modify the main_header element's css width property to be set as 100%.

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

Display hyperlinks upon hovering over text

In the sign-up form, there are options for two different types of users: teachers and students. When the sign-up option is selected, a drop-down menu with choices for teacher and student will appear. However, I would like it to function more like other w ...

The Vue instance methods provide a way to access and manipulate formatted properties

I am looking to implement a method that will generate the appropriate email format to be used as the href value in an anchor tag. This method should return the formatted string in the following format: "mailto:[email protected]". var facultyInformat ...

Tips for personalizing the Material-UI sticky header to work with horizontal scrolling

Check out this example of a Material UI table with a sticky header on CodeSandox: https://codesandbox.io/s/yi98d?file=/demo.tsx I encountered an issue where the left side header cells slide behind each other when I added a stickyHeader prop to the Materia ...

Ways to remove content that exceeds the boundaries of a div element

I am facing a challenge with a parent div that has a specified size. Inside this parent div, there are other child divs, and if any of those child divs start displaying their content outside of the parent div, I want to completely remove that div. I do not ...

Obtain the selected option from a user list

In my user table, each user is listed with a name, surname, right, and a "commit changes" button. The purpose of this setup is to assign rights to different individuals. Each column contains the userID, and the entire structure is generated from a database ...

Personalize the color scheme for your timeline paper

I am interested in customizing this specific example of a personalized timeline: import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import Timeline from '@material-ui/lab/Timeline'; import Timeli ...

What is causing Safari to block styling for <em> elements in RESET.CSS only?

I am utilizing Eric Meyer's reset.css file, which can be found at this link: Interestingly, my <em> definition in my main stylesheet is working perfectly fine on all browsers except Safari. Somehow, only in Safari, the styling for italics is no ...

Tips for creating content with ellipsis after every 5 characters

I am new to coding and I need some assistance. I want to truncate text in my navigation bar if it exceeds 5 characters by displaying the first 5 characters followed by an ellipsis. This is to prevent display issues in my nav menu. For example: Input: T ...

Does jQuery's click event not successfully hide an element on Internet Explorer?

In my dropdown menu, I have the following options: <div class="my_div"> <select name="selection" id="select_id"> <option value="0">A</option> <option value="5">B</option> ...

Using jQuery to toggle CSS properties

I'm having trouble switching between a CSS column layout and a normal layout for a div element with the ID 'article'. The jQuery script I wrote doesn't seem to work properly, as the entire thing disappears. Can anyone advise me on how t ...

Discover the procedure to alter date formats in MongoDB

I recently created a MongoDB collection using Node.js with the following code: var mongoose = require('mongoose'); var TTTUsersSchema = new mongoose.Schema({ username: String, password:String, active: Boolean, created_at: { type: Dat ...

Create a copy of an element without altering the original

Currently, I am attempting to create a duplicate of a class and ensure that it remains unaffected when the original is altered. So far, I have tried: $(".newclass").addClass("oldclass"); However, this method does not copy the content. var _elementClone ...

Sliding right is done by activating the Switch Function, while sliding to the left can be achieved by deactivating it with the help

My objective is to create a functionality where flipping the switch button will cause it to slide automatically to the right, revealing a red background div. When switched off, it should return to its original position with a yellow background using Jquery ...

I am encountering a problem while performing JavaScript validations

In jQuery or using the element's ID, I can validate a textbox. For example: var field = document.getElementById('tbxSearchField').value if (field == "") {alert("please enter text");} The HTML code is as follows: <input class="input" id ...

Ensuring that your content expands to fit the sidebar dimensions

I have diligently searched for a solution to my issue both on Google and here, but have yet to find one that works. I've experimented with various CSS properties like display: table-cell and inline-block, as well as different overflow options, but not ...

The universal CSS variables of Material UI

Creating reusable CSS variables for components can greatly simplify styling. In regular CSS, you would declare them like this: :root { --box-shadow: 0 2px 5px -1px rgba(0, 0, 0, 0.3); } This variable can then be utilized as shown below: .my-class { ...

Explore Site Configuration

When it comes to creating a responsive site with the given layouts: If you have a fixed header (4rem), how can you set up the main container (C & D) to have a maximum height of 100% and scroll independently based on the overall height of the contents in C ...

What are my choices for showcasing hierarchical information?

I'm currently working on organizing hierarchical data using HTML, JS, and jQuery. My chosen method involves utilizing a left-floated div container system in place of a grid system for easier recursive code generation. One challenge I've encounter ...

What are some creative ways to design drop-down menus within an email?

The snippet of code I am currently using lacks the ability to format text, and it does not allow content below dropdown items to shift down properly in an email. <select> <option value="first">First-time users of the Vanguard Events app:&l ...

Step-by-step guide on using nodemon on a web hosting server

I am currently designing a website that includes a login form and I am in the process of uploading it to a web hosting service In order to activate my login form, I have to use node index Is there a way to change the destination of this tag: <li class ...