Kathirirajan
Kathirirajan

Reputation: 154

How to make sure an HTML element is in the center of the window?

I want to execute a function on one element in the center of the window, and another function when leaving the element in the center. So how to make sure the HTML element is in the center of the window?

Upvotes: 1

Views: 115

Answers (1)

SHAKIR SHABBIR
SHAKIR SHABBIR

Reputation: 1295

Use following style attributes:

display: table-cell;
vertical-align:middle;
text-align:center;
height:100%;
width:100%;

Hope this solves!

Upvotes: 1

Related Questions