Jump to content

Recommended Posts

So I need help centering a DIV box...how would I do this?

 

Here is the box...feel free to try it:

<div style="border:1px  solid; width:650px; height:200px; overflow:auto;">
<div class="image">
  <a href="lol.php"> <img src="folder_icon.jpg" alt="image" class="gradualfader"  style="border: 0px dashed black;" width="50" height="50"/>
  <p>ECL Fall '09</p></a>
</div>
<div class="image">
   <a href="lol.php"> <img src="folder_icon.jpg" alt="image" class="gradualfader"  style="border: 0px dashed black;" width="50" height="50"/>
  <p>Geophysical Science</p></a>
</div>
<div class="image">
  <a href="lol.php">  <img src="folder_icon.jpg" alt="image" class="gradualfader"  style="border: 0px dashed black;" width="50" height="50"/>
  <p>Math</p></a>
</div>
</div>

Link to comment
https://forums.phpfreaks.com/topic/186779-html-center-a-div-box/
Share on other sites

That doesn't work either..on IE, it makes it go more to the right, while on mozilla firefox nothing happens.

Since my code and rajivgonsalves are two different ways of writing the same thing, I don't see how you can have got a different result.

Set "margin: 0 auto;" in the CSS (I think it's that way around anyway, if that doesn't work try it the otherway round, I always forget what order the parameters are in, I don't use CSS enough for it to stick in my mind).

 

Are you a programmer or do you use tables?

I'm more back end than design. I'm guilty of sometimes using tables for layout, but generally only for forms. For some reason I can just never remember what order the properties go for border, margin etc. in CSS. Probably because I use them so infrequently.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>

<style type="text/css">

	body {
		text-align: center;
	}

	#page-wrap {
		margin: 0 auto;
		border:1px  solid; 
		width:650px; 
		height:200px; 
		overflow:auto; 
		text-align: left;
	}

</style>

</head>

<body id="homepage">

<div id="page-wrap">

	<div class="image">
		<a href="lol.php"> <img src="folder_icon.jpg" alt="image" class="gradualfader"  style="border: 0px dashed black;" width="50" height="50"/>
		<p>ECL Fall '09</p></a>
	</div>

	<div class="image">
		<a href="lol.php"> <img src="folder_icon.jpg" alt="image" class="gradualfader"  style="border: 0px dashed black;" width="50" height="50"/>
		<p>Geophysical Science</p></a>
	</div>

	<div class="image">
		<a href="lol.php">  <img src="folder_icon.jpg" alt="image" class="gradualfader"  style="border: 0px dashed black;" width="50" height="50"/>
		<p>Math</p></a>
	</div>

</div>


</body>
</html>

 

These code will make your div centered.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.