/    Sign up×
Community /Pin to ProfileBookmark

Height is not adjusting to content placed within

Alright so, here is this page:
[url]http://thepilotsworld.com/article.php?newsid=2[/url]

As you can see there, the white background height isn’t adjusting to the content placed within.
I’ve tried several things to fix this.
So here’s the style:

[code=html]@charset “utf-8”;
/* CSS Document */

body
{
background:url(images/1600×1200.jpg)
}
#wrapper
{
width: 950px;
height: auto;
margin: 0 auto;
-moz-box-shadow: 0 0 5px 5px #888;
-webkit-box-shadow: 0 0 5px 5px#888;
box-shadow: 0 0 5px 5px #888;
}
#header
{
width: 950px;
height: 200px;
background:url(images/banner.png);
margin: 0 auto;
}
#mainContent
{
width: 950px;
min-height: 600px;
height:auto;
background-color:#FFF;
margin-top: -20px;

}
.message {
font-family: “Trebuchet MS”, Tahoma, Helvetica;
font-size: 12px;
}
hr {
width:920px;
background: #fff;
border: 0;
margin: 0px;
border-bottom: 1px solid #e3e1d9;
}
.header {
font-size: 12px;
padding: 15px;
width: 900px;
float: left;
margin-top: 15px;
margin-bottom: 15px;
text-align: left;
}
.title {
font-family: “Trebuchet MS”, Tahoma, Helvetica;
color: #423F44;
font-size: 25px;
padding-bottom: 6px;
}
a img { border:0 }
a:hover { color: #999; }
a { color: #666; }
.CommentHeader {
padding: 15px;
width: 890px;
float: left;
text-align: left;
background-color:#D3D3D3;
margin-left:15px;
opacity:0.5;
min-height:51px;
}
.CommentAuthor {
font-family: “Trebuchet MS”, Tahoma, Helvetica;
color: #333;
font-size: 15px;
text-shadow:0 1px 0 #666;
}
.CommentMessage {
font-family: “Trebuchet MS”, Tahoma, Helvetica;
color: #333;
font-size: 15px;
}
.button {
border: 1px solid #ccc;
background: #ddd;
font-family: “Trebuchet MS”, Tahoma, Helvetica;
color: #222;
font-size: 12px;
text-decoration:none;
}[/code]

And here is the page:

[code=php]<?php session_start();
?>
<!DOCTYPE html>
<html>
<head>
<link rel=”stylesheet” type=”text/css” href=”style.css” />
<link type=”text/css” href=”menu.css” rel=”stylesheet” />
<link href=’http://fonts.googleapis.com/css?family=Open+Sans’ rel=’stylesheet’ type=’text/css’ />
<script type=”text/javascript” src=”jquery.js”></script>
<script type=”text/javascript” src=”menu.js”></script>
<meta charset=”utf-8″>
<title>The Pilot’s World</title>

</head>
<body>
<?php include(“head.php”); ?>
<div id=”mainContent”>
<center>
<?php
$host=”*******”; // Host name
$username=”*********”; // Mysql username
$password=”**********”; // Mysql password
$db_name=”************”; // Database name
$tbl_name=”news”; // Table name
mysql_connect(“$host”, “$username”, “$password”)or die(“cannot connect”);
mysql_select_db(“$db_name”)or die(“cannot select DB”);
$activenews = $_GET[‘newsid’];
$activenews = stripslashes($activenews);
$activenews = mysql_real_escape_string($activenews);
$result = mysql_query(“SELECT * FROM $tbl_name WHERE id=’$activenews'”);
$count = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
$count = mysql_num_rows($result);
echo “<div class=’header’>”;

echo “<div class=’title’>”.$row[‘title’].”</div>
Published on <a href=’#’>”.date(‘jS of F, Y’, $row[‘date’]).”</a> by <a href=’user.php?user=”. $row[‘author’].”‘>”. $row[‘author’].”</a><br><br><hr><br>”;
echo “<div class=’message’>”.$row[‘message’].”</div><br><br><hr><br>”;
echo “</div>”;
if ($count == 0){
echo “<center><p>News not found!</p><p>&nbsp;</p></center>”;
}
}
$result = mysql_query(“SELECT * FROM newscomments WHERE newsid = ‘$activenews’ ORDER BY date DESC”);
$even = 1;
while($row = mysql_fetch_array($result))
{
if($even == 1)
{
echo “<div class=’CommentHeader’>”;
echo “<div class=’CommentAuthor’>”.$row[‘author’].”:</div><br />”;
echo “<div class=’CommentMessage’>”.$row[‘message’].”</div></div>”;
$even = 0;
}
else
{
if($even == 0)
{
echo “<div class=’CommentHeader’ style=’background-color:#F5F5F5′>”;
echo “<div class=’CommentAuthor’>”.$row[‘author’].”:</div><br />”;
echo “<div class=’CommentMessage’>”.$row[‘message’].”</div></div>”;
$even = 1;
}
}

}
if(isset($_POST[‘comment’]))
{
$comment = stripslashes($_POST[‘comment’]);
$comment = mysql_real_escape_string($comment);
$timestamp = time();
mysql_query(“INSERT INTO newscomments (newsid,author,message,date) VALUES (‘$activenews’,'”.$_SESSION[‘myusername’].”‘,’$comment’,’$timestamp’)”);

}
if(isset($_SESSION[‘myusername’]))
{
if($even == 1)
{
echo “<div class=’CommentHeader’>Post a comment:”;
echo “<form action=’article.php?newsid=$activenews’ method=’post’>
<input type=’text’ name=’comment’>
<input type=’submit’ value=’Post’ class=’button’>”;
echo “</form></div>”;
$even = 0;
}
else
{
if($even == 0)
{
echo “<div class=’CommentHeader’ style=’background-color:#F5F5F5′>Post a comment:”;
echo “<form action=’article.php?newsid=$activenews’ method=’post’>
<input type=’text’ name=’comment’>
<input type=’submit’ value=’Post’ class=’button’>”;
echo “</form></div>”;
$even = 1;
}
}
}
echo “<br>”;
?>
</center>
</div>
<div id=”footer”>
</div>
</body>
</html>
[/code]

So does anyone have a clue WHY this is happening.
I also have another page, where the height DOES adjust. And I already tried replacing the HTML stuff from that page into this one but no luck.

Yours sincerely,
Kevin Houghton

PS. I’m new here, I’m sorry if I’ve placed this in the wrong section.

to post a comment
HTML

4 Comments(s)

Copy linkTweet thisAlerts:
@cootheadMay 04.2013 — Hi there

and a warm welcome to these forums. ?

Change this...
[color=navy]
#mainContent {
width: 950px;
min-height: 600px;[color=red]
height:auto;[/color]
background-color:#FFF;
margin-top: -20px;
}[/color]

...to this...
[color=navy]
#mainContent {
width: 950px;
min-height: 600px;[color=red]
overflow:hidden;[/color]
background-color:#FFF;
margin-top: -20px;
}[/color]

[b]Further reading[/b]
[list]
  • [*][url=http://www.quirksmode.org/css/clearing.html]Clearing floats[/url]
  • [/list]



    [i]coothead[/i]
    Copy linkTweet thisAlerts:
    @KevinHoughtonauthorMay 04.2013 — Wow, that was a fast and a great reply! Thank you very much it is working now.

    Kevin
    Copy linkTweet thisAlerts:
    @cootheadMay 04.2013 — [indent]No problem, you're very welcome. ?[/indent]


    [i]coothead[/i]
    Copy linkTweet thisAlerts:
    @shawnmichaelsMay 10.2013 — Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic.
    ×

    Success!

    Help @KevinHoughton spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...