PDA

View Full Version : Dumb HTML question [+ REP]



Madox
07-07-2011, 10:55 PM
I want to make a image center of my page.
Not the top center but middle center.
Like a coming soon page.
And i want to add a background color to it.

Can someone give me the whole code including the html tags from top to bottom?

Thanks +REP

P.S. I know its dumb haha

Trinity
07-07-2011, 11:33 PM
http://css-tricks.com/320-quick-css-trick-how-to-center-an-object-exactly-in-the-center/

Madox
07-07-2011, 11:39 PM
I'm a coding dummie.
Can you explain how i use this in HTML?

Trinity
08-07-2011, 12:01 AM
I'm a coding dummie.
Can you explain how i use this in HTML?


<html>
<head>
<title>Title</title>

<style type="text/css">
body
{
background-color: #FFFFFF;
}

#centerImage
{
position: fixed;
top: 50%;
left: 50%;
margin-top: -50px;
margin-left: -100px;
}
</style>
</head>
<body>

<img src="URL OF THE IMAGE" id="centerImage" />

</body>
</html>

Replace the '#FFFFFF' with the colour you want the background to be.
Replace the '-50px' and the '-100px' with the correct numbers for your image (half of the height and half of the width)
Replace the "URL OF THE IMAGE" with the url of the image, obviously.

Completely untested and barely even read over to check it, but it should work.

Madox
08-07-2011, 12:15 AM
It doesn't center properly

Trinity
08-07-2011, 12:18 AM
It doesn't center properly

Screenshot?

Trinity
08-07-2011, 12:56 AM
Get rid of everything I said before, just do this, it's simpler.



<html>
<head>Title</head>

<style type="text/css">
body
{
background-color: #FFFFFF;
}

#centerImage
{
height: 100%;
width: 100%;
background: url(1.png) no-repeat center center;
}
</style>

<body>

<div id="centerImage">&nbsp;</div>

</body>
</html>

Madox
08-07-2011, 06:55 AM
A** Thanks very much!!

Want to hide these adverts? Register an account for free!