<div class="page-wrapper">
	
		<div class="pos-r">
			<h2>x and y axis</h2>
			<div class="pos-a xy-center"></div>
		</div>
		<div class="pos-r">
			<h2>x axis</h2>
			<div class="pos-a x-center"></div>
		</div>
		<div class="pos-r">
			<h2>y axis</h2>
			<div class="pos-a y-center"></div>
		</div>
	
</div>
.page-wrapper {
	width: 600px;
	margin: 40px auto;
	clear: both;
}

h2 {
	position: absolute;
	top: -30px;
	width: 100%;
	text-align: center;
	left: 50%;
	transform: translateX(-50%);
	font-family: sans-serif;
	font-size: 12px;
	text-transform: uppercase;
}

.pos-r {
	position: relative;
	width: 150px;
	height: 150px;
	border: 1px solid #333;
	margin: 0 15px;
	float: left;
}

.pos-a {
	position: absolute;
	width: 30px;
	height: 30px;
	background: #333333;
}

.xy-center {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
}

.x-center {
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
}

.y-center {
	right: 20px;
	top: 50%;
	transform: translateY(-50%);
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.