vh_center
last update:
2022/07/29
<!doctype html>
<html>
<head>
<title>vh_center4</title>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
}
body {
display: grid;
place-content: center;
}
.content {
width: 200px;
height: 120px;
background: #000;
color: #fff;
}
</style>
</head>
<body>
<div class="content">content</div>
</body>
</html>
code_popup
<!doctype html>
<html>
<head>
<title>vh_center3</title>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
}
body {
display: flex;
justify-content: center;
align-items: center;
/*-- safari5.1以前, iOS8.4以前, Android4.3以前, IE10は要prefix --*/
/*-- IE9以前は非対応 --*/
}
.content {
width: 200px;
height: 120px;
background: #000;
color: #fff;
}
</style>
</head>
<body>
<div class="content">content</div>
</body>
</html>
code_popup
<!doctype html>
<html>
<head>
<title>vh_center2</title>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
}
.content {
position: relative;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
/*-- safari5.1以前, iOS8.4以前, Android4.4以前, IE9は要prefix --*/
/*-- IE8以前は非対応 --*/
width: 200px;
height: 120px;
background: #000;
color: #fff;
}
</style>
</head>
<body>
<div class="content">content</div>
</body>
</html>
code_popup
<!doctype html>
<html>
<head>
<title>vh_center</title>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
}
.wrap {
position: relative;
min-height: 100%;
}
.content {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
width: 200px;
height: 120px;
background: #000;
color: #fff;
}
</style>
</head>
<body>
<div class="wrap">
<div class="content">content</div>
</div>
</body>
</html>
code_popup