How generate width html element to fill rest of width window

Tags: html,css

Problem :

I would ask how i can set css to set width of element to fill rest of width window screen without using unit of measure (px, pt, et).

for example i have two div

<div id="div1"></div>
<div id="div2"></div>

some css

   height: 40px;
   float: left;
   border: 1px solid black;
  width: // here what i should set to get rest of window screen until 100%,
         // depending on resolution. When i try set param auto this param 
         // work that resize my div when i put something into, but i except 
         // at start already set rest of window width. It is possible to set 
         // this value without using javascript only in CSS??
  height: 40px;
  float: left;
  border: 1px solid black;

Solution :

You could also use table layout with display: table and display: table-cell, but for this approach you need a wrapper. See Fiddle

    CSS Howto..

    How do I center my search form within a div?

    How to set link color inside GridView cell

    LESS CSS - Adding a percentage to a hex color - How does this work?

    How can I print the selected item from bootstrap drop down using jquery or javascript in php

    Sidebar, Navigation and Content how to do it?

    How to center a div and keep the alignment to its nested floating divs?

    How to put text and image in a same line?

    how to remove white space in justified css

    How to make somethings like this in CSS?

    How to create CSS styled dom element inside Google Maps InfoWindow?

    How to upload image to an existing image src in angularjs, css

    How to apply css to particular selected child in ivh-treeview?

    How to align DIV right or left or center in CSS without absolute positioning?

    How to put banner in css?

    how to set formatting of all textbox in website with css, without set cssclass property of each textbox

    React & CSS Modules: how to style components without assuming their content

    How to remove the space between inline-block elements?

    How to keep nav bar from shifting elements to next line when zooming in?

    How to load an onScroll background image before user scrolls to them?

    How to create a responsive top bar with CSS

    how to apply the css style only to child

    How to animate an icon for with CSS?

    How to set p margin for a section

    How to change the opacity background color of other two buttons once we click on a single button using css

    How to make a CSS button work correctly?

    How to style this views in drupal 7 /custom content type/?

    How to set 3 div's to fit the screen width

    How would can i keep horizontal divs (3 in a row) with margins inbetween them inline with wrapper?

    nth-of-type css, how to setup it properly

    How to make irregular CSS border