<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<title>position: absolute</title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/position.css">
</head>
<body>
<div class="elementExample elementExample_first">
Example_first
</div>
<div class="elementExample elementExample_secound">
Example_second
</div>
<div class="elementExample elementExample_last">
<div class="elementExample-internal">
Example-internal
</div>
</div>
</body>
</html>
*{
margin: 0;
padding: 0;
border: 0;
}
body{
background: #b2bec3;
font-family: "Open Sans", sans-serif;
}
ul, ol, li{
list-style: none;
}
.elementExample {
width: 200px;
height: 200px;
line-height: 200px;
color: #fff;
text-transform: uppercase;
text-align: center;
cursor: pointer;
}
.elementExample_first{
position: absolute;
right: 0;
background: #6c5c7e;
}
.elementExample_secound{
background-color: #00b894;
position: absolute;
top: 50%;
left: 50%;
/*transform: translateX(-50%) translateY(-50%);*/
transform: translate(-50%, -50%);
}
.elementExample_last{
background: #d63031;
position: absolute;
}
.elementExample-internal{
width: 100px;
height: 100px;
line-height: 100px;
background-color: #00cec9;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}