Центриране на съдържание

  • Автор Автор Foxy
  • Начална дата Начална дата

Foxy

Registered
Здравейте! Пробвах си да си центрирам съдържанието (което е с float left). Гледах от тази тема http://web-tourist.net/forum/viewtopic.php?t=73041 обаче нещо не става. Ето кода:

Код:
<?php
session_start();
include "config.php";
$username = $_SESSION['username'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<meta http-equiv="content-type" content="text/html; charset=windows-1251" />
	<meta name="author" content="carbonated" />
	<link rel="stylesheet" type="text/css" href="css/csshorizontalmenu.css" />

	<script type="text/javascript" src="js/csshorizontalmenu.js">
	/***********************************************
	
	* CSS Horizontal List Menu- by JavaScript Kit (www.javascriptkit.com)
	* Menu interface credits: http://www.dynamicdrive.com/style/csslibrary/item/glossy-vertical-menu/ 
	* This notice must stay intact for usage
	* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more
	
	***********************************************/
	</script>
<style type="text/css">
A:link {text-decoration: none; color: #7e9147;}
A:visited {text-decoration: none; color: #7e9147;}
A:active {text-decoration: none; color: #7e9147;}
A:hover {color: #b6d55d;}
</style>
	<title>Hardware-Maniac.com - Начало</title>
</head>

<body>
<div class="horizontalcssmenu">
<ul id="cssmenu1">
<li style="border-left: 1px solid #9cbb44;"><a href="index.php"><font color="#475816"><b>Начало</b></font></a></li>
<li><a href="statii.php" ><font color="#475816"><b>Статии</b></font></a></li>
<li><a href="products.php"><font color="#475816"><b>Продукти</b></font></a>
<ul>
<?php
$za = "SELECT * FROM `kategorii`";
$res = mysql_query($za) or die (mysql_error());
while($r=mysql_fetch_assoc($res))
{
	echo "<li><a href='products.php?kat=$r[id]'>$r[kategoriq]</a></li>";
}
?>
</ul>
</li>
<li><a href="forum"><font color="#475816"><b>Форум</b></font></a></li>
</ul>
<br style="clear: left;" />
</div>
<br />
</body>
</html>
<?php

$result = mysql_query("SELECT * FROM `statii` ORDER BY `id` DESC LIMIT 0,5") or die (mysql_error());
echo "<div style='float: left;'><div style='width: 330px; height: 25px; background: url(images/laststatii.png) no-repeat; padding-top: 5px; padding-left: 15px;'><font color='#67860d'><b>Последно добавени статии</b></font></div>
<div style='width: 308px; border: 1px solid #9cbb44; padding: 10px;'>";
while($data = mysql_fetch_assoc($result))
{
	echo "<tr><td> <font size='1' face='Times New Roman' color='#9cbb44'> » </font> <a href='statii.php?statiq=$data[id]'>$data[zaglavie]</a></td></tr><br />";
}
echo "</div></div><br />";

$resultat = mysql_query("SELECT * FROM `produkti` ORDER BY `id` DESC LIMIT 0,5") or die (mysql_error());
echo "<div style='float: left;'><div style='width: 330px; height: 25px; background: url(images/lastprodukti.png) no-repeat; padding-top: 5px; padding-left: 15px;'><font color='#67860d'><b>Последно добавени продукти</b></font></div>
<div style='width: 308px; border: 1px solid #9cbb44; padding: 10px;'>";
while($data = mysql_fetch_assoc($resultat))
{
	echo "<tr><td> <font size='1' face='Times New Roman' color='#9cbb44'> » </font> <a href='products.php?product=$data[id]'>$data[model]</a></td></tr><br />";
}
echo "</div></div>";

?>
 
Код:
<div id="glaven">

   <div style="height:100px; float:left; width:100px;">left</div>
   <div style="height:500px; float:left; width:100px;">center</div>
   <div style="height:100px; float:left; width:100px;">right</div>
   <div style="clear:both;"></div>

</div>

Код:
#glaven {
   margin:0 auto;
   width:300px;
}
 
shterev каза:
Код:
<div id="glaven">

   <div style="height:100px; float:left; width:100px;">left</div>
   <div style="height:500px; float:left; width:100px;">center</div>
   <div style="height:100px; float:left; width:100px;">right</div>
   <div style="clear:both;"></div>

</div>

Код:
#glaven {
   margin:0 auto;
   width:300px;
}

+1
 
вече според това какви са ти ширините задаваш ширина на главния.
 

Back
Горе