Adjust div elements to fit the size of the window

I'm currently working on designing a new web application's skeleton layout. I have come across some issues, particularly with CSS layouts and DIV.

1) Boxes 1 and 2 in the first column do not align with boxes 3 and 4 in the second and third columns. How can I fix this alignment?

2) I admire how the interface on this website automatically adjusts its size when minimized or maximized. I've been trying to replicate this feature in my design but haven't been successful. The footer is also causing some trouble by sticking out. I want everything to be contained on one page like the mentioned website. How can I achieve this?

Thank you for your help in advance.

HTML:

<!--  
============================================
LOGO
============================================
-->

<div id="wrapper">
    <div class="logo">logo</div>

<!--   
============================================
NAVBAR
============================================
-->   

<div id="header">
    <a href="#">link 1</a>
    &nbsp;|&nbsp;
    <a href="#">link 2</a>
    &nbsp;|&nbsp;
    <a href="#">link 3</a>
    &nbsp;|&nbsp;
    <a href="#">link 4</a>
</div>

  <div style="clear: both;"></div>

<!--  
============================================
NAVIGATION & CONTACTS
============================================
-->

<div class="column" id="first-column">
    <div class="window" id="window-1">1</div>
    <div class="window" id="window-2">2</div>
</div>

<!--   
============================================
MAIN CONTENT
============================================
-->

<div class="column" id="second-column">
    <div class="window" id="window-3">3</div>
</div>

<!--
============================================
CHAT
============================================
-->

<div class="column" id="third-column">
    <div class="window" id="window-4">4</div>
</div>

<!--  
============================================
FOOTER
============================================
-->

        <div style="clear: both;"></div>
        <div class="footer">footer</div>
</div>​

CSS:

/*
============================================
GENERAL
============================================
*/

body, html{
    font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
    height: 100%;
}

/*
============================================
LAYOUT SKELETON
============================================
*/

#wrapper {
    margin: 0 auto;
    max-width: 1212px;
    min-height: 540px;
    min-width: 784px;
    position: relative;
    height: 100%;
}

#header{
    text-align:right;
    padding:5px;
    font-size:10px;
    padding-right: 30px;
}

#first-column{
    width: 20%;
    padding-left: 5px;
    height: 100%;
}

#second-column{
    width: 50%;
    height: 100%;
}

#third-column{
    width: 25%;
}

.window{
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    border:1px solid #CECECE;
    width:100%;
}

#window-1{
    height:50%;
}

#window-2{
    margin-top:10px;
    height:50%;
}

#window-3{
    height: 100%;
}

#window-4{
    height:100%;
}

.column{
    float:left;
    margin: 5px;
    height: 100%;
}

.logo {
    font-family: arial;
    font-size: 12px;
    float: left;
    padding-left: 10px;
}

.footer {
    margin-top: 10px;
    padding-left: 10px;
}

Answer №1

When designing your layout, it's important to consider the margins and height of each column. In column 1, with two divs at 50% height, there will naturally be more margin space compared to column 2 which only has one div. To address this imbalance, you can add a padding of 10px to the bottom of the columns. This will help align the margins more evenly.

Another helpful tip is to set a min and max width for your elements, then specify a percentage width. For example, you can set a minimum of 100px, maximum of 300px, and a width of 50%. This way, the element will adjust its size between 200px to 600px wide, staying within the specified range.

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

Manipulating contextual selectors

Have you ever tried reverting or overriding attributes from contextual selectors? .card { padding-top: 20px; ... } .card .card-header { padding: 0 20px; } .card .card-header.news { padding-top: 0px; } Do you think it's possible to elimina ...

The function TagBuilder.MergeAttributes is malfunctioning

My attempt at creating a custom helper in MVC is not working as expected. The custom attributes are not being added to the HTML: Custom Helper Function public static MvcHtmlString MenuItem(this HtmlHelper helper, string linkText, string actionName, strin ...

Jspsych: Centering and aligning 3 p tags to the left on the page

Feeling pretty stuck at the moment. Here's what I have visually right now: I added a caption in Comic Sans and an arrow using MS Paint. Each line with color swatches is wrapped in a p tag. The goal is to center these p tags on the page (as they are ...

Arranging divs within a wrapper, ensuring that one of them displays a vertical scrollbar when the content exceeds the space available

I'm currently facing a challenge with defining the height of the description box in order to achieve the layout shown. I am trying to find a solution without relying on javascript. https://i.stack.imgur.com/3j278.png At present, the wrapper and titl ...

Utilize JavaScript to trigger a function depending on the selected options from dropdown menus

I've been working on a fun little project for a web page where users can select two items from a drop-down menu and then click a button to play a sound corresponding to their selections. However, I'm facing some challenges with getting my JavaScr ...

What is the method for specifying the HTML file extension within Visual Studio?

I am having issues with my project recognizing the CSS and other files in the HTML files I have created, even though I have double-checked the extension paths. How can I resolve this problem? https://i.stack.imgur.com/85ooE.png https://i.stack.imgur.com/F ...

Managing iframe scrolling using the parent window's scrollbar

I am currently working on an iframe to be utilized across various domains. The functionality of this iframe involves displaying a data list that updates when the bottom of the scroll is reached. An issue I encountered is that the parent window, where the ...

Is it possible for a div with fixed position to still have scrolling functionality

My fixed positioned div (#stoerer) appears to be moving while scrolling, although it is just an optical illusion. Check out this visual explanation: view gif for clarification Below is the code snippet in question: <div id="stoerer"> <button ...

What is the best way to ensure that two div elements within a list element fully utilize the available width on a webpage?

I am looking to create a 'settings' div that adjusts its width based on the available space on a page. This could range from 1000px to 600px, and I want the div to always be next to the 'title' div without wrapping onto the next line. F ...

concealing the date selection feature on the data picker

$('.year').datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, dateFormat: 'MM yy', onOpen: function(dateText, inst) { $("table.ui-datepicker-calendar").addClass('hide') }, onClos ...

Ensuring DIV Fills without Compromising Aspect Ratio

I am currently attempting to fill a div with an image in both width and height. However, I have only been able to control the width while the height respects the aspect ratio without filling the div completely. I have tried various combinations of backgrou ...

In CSS, use the p tag to make sure content fills the available space when the browser is resized beyond a certain point

Before I begin, I must clarify that I do not specialize in front-end development and my expertise in UI/UX is limited. With that said, here is my query: I have a div containing p tags. I wish for this div to have a width: 700px when the browser window is ...

Is it advisable to avoid using `&apos;` for escaping single quotes?

According to the insights shared in conversations about the popularity of single quotes in HTML and Jquery embedded quote in attribute, the Wikipedia page on HTML highlights that: The use of the single-quote character ('), as a way to quote an attri ...

Tips for including a decimal point in an angular reactive form control when the initial value is 1 or higher

I am trying to input a decimal number with 1 and one zero like 1.0 <input type="number" formControlName="global_velocity_weight" /> this.form = this.fb.group({ global_velocity_weight: new FormControl(1.0, { validators: [Valida ...

How can one retrieve elements from a loaded webpage?

I've been using the jQuery function .load() to load a page and I'm trying to find a way to access HTML elements within the loaded page from the source page once it's finished loading. The only method I've come across so far is to add pa ...

Styling div elements to match the dimensions of table rows in CSS

When it comes to CSS, I wouldn't call myself an expert; My question is: is there a way for a div tag to inherit dimensions from specific table rows based on their class or id? For instance: Imagine we have a table with multiple rows, but we don&apos ...

Unusual SVG Cubic Bezier Animation Transforming Curves into Points and Lines

As a beginner in SVG CSS animation, I am currently working on morphing three curved paths into three rectangles using cubic bezier routes. While I have managed to make it work, there is an issue during the transition where parts of it skew inward in a stra ...

Is there a way to modify the color scheme of the hamburger icon

I'm experiencing difficulties changing the color of a hamburger icon. I've searched for the specific code responsible for the color change, but I haven't been able to locate it. Ideally, I want the color to be white, but on small screens, i ...

The peculiar effect of a CSS element's border on surrounding elements is quite unusual

I'm experiencing a strange issue that I can't quite figure out. To demonstrate the problem, I've created a fiddle. What's puzzling me is why applying a border to one of the three canvases causes my other two .headerMainDiv elements to ...

Can Webpack be used to produce only CSS files without generating the output.js file?

I've integrated Webpack into my project alongside the extract-text-webpack-plugin. Within my project, I have various build scripts. One of these scripts focuses solely on bundling and minifying CSS. While utilizing Webpack for other tasks, I decided ...