Adjust the size of the content to fit the window dimensions

I am currently in the process of designing a new website, but I am facing difficulties with resizing the content to fit the actual window size. As they say, a picture is worth a thousand words. The first image shows how it should look, while the one below demonstrates the issue when I resize the window.

<div class="header">
<div class="hdrmast-topbar">
    <div class="container">
        <span>Test :: Link 1 | Link 2</span>
    </div>
</div>

In the header section, I plan to have two bars, with one being the hdrmast-topbar as shown in the code snippet. The parent element will be fixed and scroll along with the page. However, my goal is to make the content resize automatically according to the window size, similar to what can be seen on this example website:

Currently, the header is set to a relative position, as I am still experimenting with different approaches.

/* Header */

.header { min-width: 100%; position: relative; }
.hdrmast-topbar { background-color: #000; width: 100%; max-height: 25px; font-size:   11px; color: #fff; font-weight: bold; text-align: right; padding-top: 5px; padding-bottom: 5px; }
.hdrmast-topbar span { margin: 0; padding: 0; }

/* Global */

.container { width: 1120px; margin: 0 auto; }

Thank you for your assistance.

Answer №1

Simply eliminate

.wrapper { max-width: 960px;

replace it with max-width: 100%;...

Answer №2

To achieve the desired layout, consider setting a maximum width of 1120px for the container while maintaining its width at 100%.

​.container{
    margin: 0 auto;
    background:blue;
    max-width:1120px;
    width:100%;
}​

For a demonstration, you can view this setup on JsFiddle: http://jsfiddle.net/tDjA9/2/embedded/result/

I hope this solution addresses your question accurately. If not, please let me know. :-)

Edit--

If you intend to replicate the website's design, consider using position:fixed instead.

You can see an example of this in action on a new jsfiddle I created: http://jsfiddle.net/tDjA9/6/embedded/result/ :-)

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

Click the button on the form without actually submitting it

I have created a form that includes the use of two tags. The issue I am facing is that every time the user clicks on them, the form gets submitted. I tried using onclick="return false" to prevent this behavior, but the values are not being sent in the UR ...

Having multiple divs lined up horizontally on a single row

I am trying to create three divs in a single row similar to this: https://i.sstatic.net/A63Sx.png Any assistance on how to achieve this setup would be greatly appreciated. ...

A guide on accessing the href attribute of an HTML tag using jQuery

My goal is to extract the ID from the href attribute of an a tag on my webpage. First, I need to prevent the page from refreshing before performing this task. The example a tags look like this: '<a href="/ArtPlaces/Delete/5">Delete</a>&ap ...

Is there a way I can create a slight gap between the icon and the text in this area?

After learning Reactjs and JavaScript, I have encountered a problem that I need advice on. In the image provided, the "Sign in" text does not have proper spacing between the icon and the text, unlike the other menu items. https://i.stack.imgur.com/b663b. ...

Issues arise when trying to use the Jquery append() method in conjunction with Angular

We are currently utilizing jquery version 1.9.1 and angular version 1.2.13 for our project. Our wysiwyg editor is functioning well, as we are able to save HTML into the database and load it back using the jquery append function successfully. However, we ar ...

Is there a way to align both JSX elements in a single row without having one overlap the other?

Is there a way to showcase both conditions side by side on the same line? If Condition 1 is met, display the images; if Condition 2 is met, show the video. import React, { useState } from "react"; import { Card } from "react-bootstrap" ...

Storing the values of three checkboxes in individual variables to be passed into distinct columns

Below is the HTML code for checkboxes, with a function that limits only three selections: <form class="interestSearchCriteria"> <input type="checkbox" name="walking" value="Walking"> Walking <input type="checkbox" name="running" value=" ...

Is it possible to display a div when hovering over it and have it remain visible until

How can I make the div ".socialIconsShow" fade in when hovering over ".socialIcons", and then fade out when hovering over ".socialIconsShow"? Is there a way to keep the icons visible even after leaving ".socialIcons"? <div class="socialNetworks"> ...

Switching from Wordpress to Django and completely revamping the website using only Django

I have a webpage that currently has wordpress.org preinstalled, but I have never utilized it. Now, as I am exploring django, I am interested in using it to build my website instead of relying on wordpress. Can someone guide me on how to transition from wo ...

"Combining JSON, JavaScript, and HTML for dynamic web development

I am a junior computer programmer facing challenges with our JSON project. The objective is to store an object in local storage, but my HTML and JS code are not working as intended. It seems like nothing happens at all. Any suggestions or feedback would ...

Leveraging React Native to position a view absolutely in the center of the screen without obstructing any other components

How can I center an image inside a view in the middle of the screen using position: "absolute"? The issue is that the view takes up 100% of the width and height of the screen, causing all components underneath it (such as input fields and buttons ...

Personalize the font style of the icon property in Material UI Table when utilizing text in place of an icon

In my React app using Material UI table, I needed a custom event on the action button that displayed text instead of the usual icons for Add, Update, or Delete. Instead of creating my own icon, I opted to use text for the button like so... <MaterialTabl ...

Steps for setting up a barcode scanner on a smartphone (both iPhone and Android) using zxing in an html app

After reviewing different answers to my questions, I decided to try out some solutions below. The app and camera function properly on Android devices, but not on iPhones. What steps should I take? <!DOCTYPE html> <HTML> <HEAD> <script ...

Obtain the location of the image source from a text file within an HTML document

I need to create a slideshow displaying a sequence of images. The path to these images will be stored in a text file. How can I read the image paths from the text file? Currently, I have hardcoded code like the example below: <div class="mySlides fade" ...

Ways to hide an element when scrolling for a better user experience

I am encountering an issue with a custom icon element in my table. The icon is supposed to only be displayed when its specific row is hovered over. However, when I scroll down without moving my mouse, the hover state does not update and the icon remains on ...

`Videos on youtube with elements overlapping each other`

Having an issue with YouTube videos where other elements (LayerSlider) are overlapping on top of them. You can see the problem by clicking on this link () and trying to make the video fullscreen. I found a similar issue mentioned in the following link: Y ...

``Inconvenience of Extensive URLs Being Displayed in Tables

I've been struggling to find a solution for the problem I'm facing with Chrome when it comes to wrapping long URLs in a table cell. Despite trying various solutions found online, including using the CSS code word-wrap: break-word;, I have not bee ...

Unique symbols within HTML tags

Many times when the topic of HTML attributes is brought up, people are referring to the value of the attribute. However, I am interested in discussing the actual attributes themselves. Would you consider the following code snippet to be valid? <a href= ...

New to the game: validating JavaScript forms on the go

I recently developed a form that requires JavaScript validation. Despite referencing a post about inline JavaScript form validation on Stack Overflow, I struggled to replicate the desired outcomes. To aid in troubleshooting, I have set up a JSBin link tha ...

How can AngularJS utilize variables from an external JavaScript <script> file within an HTML document?

As someone unfamiliar with AngularJS, I have a simple inquiry regarding the subject. The code on my page begins by defining an app and controller: <script> var isisApp = angular.module('isisApp', []); isisApp.controller('Acco ...