Solved

vvveasy center image

Posted on 2003-11-28
4
284 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

786 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