Help us understand the problem. What is going on with this article?

【メモ】高さをcssで%指定し、可変に。

More than 5 years have passed since last update.

高さを%で指定し、可変にする


height:calc(80%);

説明下手なので、サンプルで。。
コピペして確認してください。すみません。
↓↓↓↓↓

html
<html>
<body style="text-align:center;">
<div style="height:100%">
<div style="height:60px;">
header<span style="color:#ccc;">(60px)</span>
</div>
<div style="border:1px solid blue;height:calc((100% - 120px) / 2)">
BOX 1 <span style="color:#ccc;">(100% - 120px) / 2</span>
</div>
<div style="border:1px solid red;height:calc((100% - 120px) / 2)">
BOX 2 <span style="color:#ccc;">(100% - 120px) / 2</span>
</div>
<div style="height:60px;">
footer<span style="color:#ccc;">(60px)</span>
</div>
</div>
</body>
</html>

訂正

<!doctype html>
<html>
<head>
<style>
  html, body { width: 100%; height: 100%; margin: 0; padding: 0; }
  * { box-sizing: border-box; }
</style>
</head>
<body style="text-align:center;">
<div style="height:100%">
  <div style="height:60px;">
    header<span style="color:#ccc;">(60px)</span>
  </div>
  <div style="border:1px solid blue;height:calc((100% - 120px) / 2)">
   BOX 1 <span style="color:#ccc;">(100% - 120px) / 2</span>
  </div>
  <div style="border:1px solid red;height:calc((100% - 120px) / 2)">
   BOX 2 <span style="color:#ccc;">(100% - 120px) / 2</span>
  </div>
  <div style="height:60px;">
   footer<span style="color:#ccc;">(60px)</span>
  </div>
</div>
</body>
</html>

コメントにてご指摘をいただきました。
訂正させていただきます。
@irxground さん、本当にありがとうございます!(2014/6/5)

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away