Solved

Dead Center on the Page

Posted on 2012-12-31
1
284 Views
Last Modified: 2012-12-31
I am trying to center a small amount of text (1-5 words) in the dead center of the page. I am not just talking about horizontal centering (<center></center>) but also vertical centering. I would like the text to always be in the very center of the window. Is there an easy way of doing this?
0
Comment
Question by:stakor
1 Comment
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 310 total points
ID: 38733891
This seems to work

http://jsbin.com/oquzuj/1/

<!DOCTYPE html>
<html>
<head>
<style>
.center {
  position: fixed;
  top: 50%;
  left: 50%;
  margin-top: -50px;
  margin-left: -100px;
  background: #000;
  color:fff;
  padding:10px;
}
</style>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div class="center">I am the center</div>
</body>
</html>

Open in new window

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now