Changed static divs into flexible divs

I am currently working on designing a webpage layout where the header occupies 100% of the width and 20% of the height in conjunction with a left navbar (20% width) and a main body adjacent to it (80% width). Additionally, I want the page to be responsive so that it maintains its aspect ratio on screens of different sizes.

html

<!doctype html>
<html lang="en">
<head>
    <title>Test</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>

  <div class="header">


  </div>

  <div class="left">

  </div>

  <div class="main">

  </div>

</body>

</html>

In the CSS section below, you'll notice fixed properties are commented out. How can I achieve a responsive layout?

#header{
    height:20%;
    width:100%;
    background-color: #3B3738;
    /*min-height:80px;
    min-width: 100%;*/
}

#left{
    height:80%;
    width:20%;
    background-color: #848484;
    /*min-height:550px;
    min-width:20%;
    position: relative;
    float:left;*/
}

#main{
    height:80%;
    width:80%;
    background-color: #FDF3E7; 
    /*min-height:550px;
    min-width:80%;
    position: relative;
    float:left;*/
}

Answer №1

If you're unsure about how to approach your task, consider utilizing Twitter Bootstrap. It provides pre-made classes and CSS for achieving the functionality you desire.

Check out their website here: http://getbootstrap.com/

The documentation on their grid system can be found at this link: http://getbootstrap.com/css/#grid

I hope this information proves helpful to you.

Answer №2

Happy to report that I managed to find a resolution for my issue by utilizing vh and vw units in my CSS rather than relying on percentages or pixels. It's a neat and straightforward fix that aligns perfectly with the requirements of my project.

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

jQuery - accessing a different class within the object

Let me explain the scenario: I have a website that will delve into 4 different subjects. Initially, I have 4 divs each representing the title of those subjects. For instance, <div><p> Physics </p></div> <div><p> Chem ...

Could someone please explain why my ajax is not functioning properly?

I have been working on an AJAX function to pass input values from one page to another. However, I am facing a challenge where the value is not being passed as expected after redirection. Despite my efforts, I cannot figure out why it's not functionin ...

The reverse is concealed following a CSS flip transition

After applying a CSS flip animation to a card, the backside isn't visible once flipped. Here is the HTML code for the card component named "ptree-card": <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <!-- Rest of th ...

How to retrieve an element's background color in hexadecimal using jQuery

I am attempting to retrieve the background colors of elements. $(document).ready(function(){ $.each('.log-widget',function(){ console.log($(this).css('backgroundColor')); //$(this).css({'box-shadow':'1px 1px ...

Upload the PDF file along with other form data in a React application

I'm currently facing an issue with using formData for submitting a pdf file const [file,setFile] = useState() const [isFilePicked, setIsFilePicked] = useState(false); I have an input of type file <input accept=".pdf" type="file&quo ...

Is there a way to retrieve all child nodes of an element, including the text nodes, from a Selenium WebElement?

Looking for help with parsing this Java Selenium application element: <span class="text-small-teaser d-none d-sm-inline-block cut-job-address swissdev-grey-text"> <span class="icon-building mr-1" aria-hidden="true" ...

Div behaving as a radio input

I have customized radio buttons to look like buttons using JavaScript. However, on page load, both buttons automatically receive the 'active' class instead of only when they are selected. Additionally, the fadeToggle function in the if-statement ...

JavaScript for Dynamic Scaling Animations

I am currently working on animating an SVG button and I am trying to incorporate the transform property with a fadeout using opacity attributes in Javascript. This is how I have attempted to write the code: (Starting with opacity 0 and scale 0) (I am awa ...

I am facing an issue with my react-app where it compiles successfully without any errors, but it is not rendering any elements

JavaScript file to run with npm start: import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter as Router } from 'react-router-dom'; import Routes from './routes'; ReactDOM.render( <R ...

Issue with Bootstrap datepicker functionality within a modal

I've searched extensively on Google and Stack Overflow for a similar question, but so far haven't been successful. The issue I'm facing is when I create and open a modal from jQuery and try to access a date picker, the datepicker's Java ...

Vue.js fails to show Font awesome icon

Currently, I am attempting to incorporate a font-awesome arrow icon using my CSS code as seen below: <style> .negative { color: red; } .positive { color: green; } .negative::after { content: "\f106"; } </style> Despite ...

Designing the Structure for a Private Network System

In the works is a plan to develop a production application catered towards small and medium businesses. The target for this intranet application is 15 to 30 concurrent users. The proposed architecture includes: Client: Firefox browser UI: HTML, JavaScrip ...

Creating a FadeIn animation for a hidden div element by using the display:none property

Struggling to implement a fadeIn function for a div tag with a display:none property. How can I make the div tag visible and smoothly fade in while still keeping the display:none property? Attempted solution so far: <div class="graphs_line_based cle ...

Auto-closing dropdown menus in the navbar of a Shiny app with Bootstrap

Is there a way to customize the behavior of a shiny navbarMenu so that when I click inside or outside it, the dropdown does not automatically hide? I have seen mentions of using data-bs-auto-close="false" in the Bootstrap documentation, has anyon ...

If there are no spaces, text will be removed from my list group

While working on developing a forum, I encountered an issue where if I repeatedly input letters or words without any spaces, it causes everything to overlap. Below is an example highlighting this problem: https://i.sstatic.net/KStNq.png Although there is ...

An effective method for cutting off text while preserving HTML styling using jQuery

Is there a way to truncate text using jQuery while preserving the HTML formatting? I attempted the code below, but it doesn't maintain the HTML tags. var truncate = function() { $('p.truncated').text(function(index, oldText) { if (old ...

Issue with background image resizing when touched on mobile Chrome due to background-size property set to cover

My current challenge involves setting a background image for a mobile page using a new image specifically designed for mobile devices. The image is set with the property background-size: cover, and it works perfectly on all platforms except for mobile Chro ...

Update location when visibility changes

Looking for a way to automatically refresh an HTML page when a specific div becomes visible, but seems like I am missing something. There is a JavaScript code, divslide.js, that changes the display style of the div from none to inline at predetermined time ...

What is the best way to retrieve the values of a select element from LEVEL 4 within the form submission of LEVEL 3?

To enhance readability, the intricate code has been abstracted. Within our Angular 2 project, we are working with a component called <top-component> (LEVEL 1): <top-component> </top-component> This component includes a template known a ...

CSS is not appearing on my Node.js server application

The code snippet below is from my node.js server (using express): app.get('/appointment/:id',function(req,res){ res.writeHead(200,{'Content-Type':'text/html'}); res.write('<link href="public/css/style.css" rel="st ...