HTML left, center, right adaptive layout (using calc css expression)

HTML left, center, right adaptive layout (using calc css expression)
In the latest HTML standard, there is a calc CSS expression that we can use to calculate the layout.
But it is not supported in the old IE. In order to support all browsers, js is used here.
screenshot:

code:

Copy code
The code is as follows:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD LEVEL1//EN">
<html>
<head>
<title>MyHtml.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script>
var left,center,right,width;
window.onload = function(){
left=$('left');
center=$('center');
right=$('right');
onresize();
};
window.onresize = function() {
try {
width = document.body.clientWidth;
center.style.width = (width - left.clientWidth - right.clientWidth - 0) + "px";
}catch(e){
//If it is less than 0, an error will be reported
}
};
function $(id){
return document.getElementById(id);
}
</script>
<style>
body,html{
height:100%;
margin:0px;
padding:0px;
overflow:hidden;
}
#left,#center,#right
width:200px;
height:100px;
background-color:rgb(34,124,134);
float:left;
height:100%;
}
#center{
background-color:red;
}
</style>
</head>
<body>
<div id="left"></div>
<div id="center"></div>
<div id="right"></div>
</body>
</html>

<<:  PHP-HTMLhtml important knowledge points notes (must read)

>>:  Vue achieves the top effect through v-show

Recommend

How to customize Docker images using Dockerfile

Customizing images using Dockerfile Image customi...

Embed codes for several older players

The players we see on the web pages are nothing m...

Five solutions to cross-browser problems (summary)

Brief review: Browser compatibility issues are of...

Detailed installation tutorial of zabbix 4.04 (based on CentOS 7.6)

1. Preparation before installation: 1.1 Install J...

Some conclusions on developing mobile websites

The mobile version of the website should at least...

Detailed tutorial on installing mysql on centos 6.9

1. Confirm whether MySQL has been installed. You ...

Mysql example of splitting into multiple rows and columns by specific symbols

Some fault code tables use the following design p...

Use Angular CDK to implement a Service pop-up Toast component function

Table of contents 1. Environmental Installation 2...

Solution to MySQL error code 1862 your password has expired

The blogger hasn't used MySQL for a month or ...

Who is a User Experience Designer?

Scary, isn't it! Translation in the picture: ...

Discuss the value of Web standards from four aspects with a mind map

I have roughly listed some values ​​to stimulate ...

Understand all aspects of HTTP Headers with pictures and text

What are HTTP Headers HTTP is an abbreviation of ...

What you need to understand about MySQL locks

1. Introduction MySQL locks can be divided into g...