Solved

vvveasy center image

Posted on 2003-11-28
4
283 Views
Last Modified: 2012-08-14
i'm a very bloody n%b in this,
I just want to center an image horizontal & vertical acording to the window size
nothing else is on the page
0
Comment
Question by:dkloeck
  • 2
4 Comments
 
LVL 31

Expert Comment

by:seanpowell
ID: 9838464
If it's the only thing on the page, then use the CSS background property:

<html>
<head>
<style type="text/css">
<!--
body {background-image: url(myimage.gif); background-position:center center; background-repeat:no-repeat; }
//-->
</style>
</head>
<body>
</body>
</html>
0
 
LVL 10

Author Comment

by:dkloeck
ID: 9838524
but the image is a link to another page, isn't there another way?
0
 
LVL 31

Accepted Solution

by:
seanpowell earned 20 total points
ID: 9838576
Absolutely:

<html>
<head>
<title></title>
<style type="text/css">
<!--
div#myimage {
position: absolute;
top: 50%;
left: 50%;
margin-top: -40px;
margin-left: -100px;
}
//-->
</style>
</head>
<body>
<div id="myimage">
<A href="index.html"><img src="image.gif" width="200" height="80"></a>
</div>
</body>
</html>

The negative margins are 1/2 the width and height of the image.
0
 

Expert Comment

by:Kane00
ID: 9840922
You can use this code. It is simply a table!

<html>

<head>
<title>Example</title>
</head>

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">

<table border="0" cellpadding="0" style="border-collapse: collapse" width="100%" height="100%">
      <tr>
            <td style="text-align: center">
            Place your image here, with the links and everything.
            </td>
      </tr>
</table>

</body>

</html>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 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

26 Experts available now in Live!

Get 1:1 Help Now