2

だから私はブログを作っていますが、ユーザーがログインしていないときに投稿を含む div には背景色が表示されません。

だから、ここに私がログインしているときにどのように見えるかのイメージがあります: ここに画像の説明を入力

ログアウトすると、次のように表示されます。 ここに画像の説明を入力

私のインデックスページは次のとおりです。

<?php
    ini_set('date.timezone', 'Europe/London');
    include_once('init.php');

    date_default_timezone_set('Europe/London');

    mysql_query("SET time_zone = timezone;");

    session_start();

    $posts = get_posts();
?>

<!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">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <LINK REL=StyleSheet HREF="style.css" TYPE="text/css" MEDIA=screen>
    <title>Home - Chris's Blog</title>
</head>

<body>
    <div id="universe">
        <h1>Chris's Blog</h1>

        <div id="content">
            <div id="menu">
                <?php 
                    $temp = $_SESSION['username'];
                    $real = get_full_name($temp);

                    if(isset($_SESSION['username']))
                    {
                        echo '<br />'.'Welcome back, '. $real['name'] . ' ' . $real['last_name'] . '.';
                    }
                ?>
                <?php
                    $timezone = date_default_timezone_get();
                    echo '     The current server timezone is: ' . $timezone ; 
                ?>
                <p>&nbsp;</p>
            </div>
            <div id="subcontent">
            <div id="posts">
                <?php
                    foreach( $posts as $post)
                    {
                        if( ! category_exists('name', $post['name']))
                        {
                            $post['name'] = 'Uncategorized';
                        }
                ?>
                <div class="post">
                    <div id="post_title">
                    <h2><a href="index.php?id=<?php echo $post['post_id']; ?>"><?php echo $post['title']; ?></a></h2>
                    <p>
                        Posted on <?php echo date('d-m-Y h:i:s', strtotime($post['date_posted'])); ?> in <a href="category.php?id=<?php echo $post['category_id']; ?>"><?php echo $post['name']; ?></a> ip: <?php get_ip(); ?>
                    </p>
                </div>
                <div id="post_content">
                    <?php echo nl2br($post['contents']); ?>
                </div>
            <?php // check if session has been set
                if(isset($_SESSION['username']))
                {
            ?>
                <div id="post_edit">
                    <p><a href="delete_post.php?id=<?php echo $post['post_id']; ?>">delete</a></p>
                </div>
            <?php
                }
        ?>
            </div>
        <?php
            }
        ?>
        </div>
        <div id="rightbar">
            <ul>
                <li><a href="index.php">Home</a></li>
                    <?php 
                        if( isset($_SESSION['username']))
                        {
                            echo '<li><a href="add_post.php">Add Post</a></li>', '<li><a href="add_category.php">Add Category</a></li>', '<li><a href="logout.php">Logout</a></li>';
                        }
                    ?>
                <li><a href="index.php">Contact</a></li>
                    <?php
                    if(! isset($_SESSION['username']))
                        {
                            echo '<li><a href="login.php">Login</a></li>';
                        }
        ?>
            </ul>
        </div>
    </div>
</div>
</div>
</body>
</html>

そして私のCSS:

@charset "UTF-8";

body
{
background-color:#CCC;
}

#universe
{
    margin:0 auto;
    width:800px;
    height:auto;
}

.post
{
    font-style:normal;
    /*margin-left:10px;
    margin-right:10px;*/
    margin:0px auto;
    width:580px;
    background-color: #CCC;
}
#posts
{
    float:left;
    width:600px;
    /*min-height:100px;*/
}
#menu
{
    float:left;
    width:790px;
    height:50px;
    background-color:#09F;
    padding-left:10px;
}
#subcontent
{
    float:left;
    width:800px;
    min-height:100px;
    background-color:#666;
}
#rightbar
{
    width:200px;
    float:right;
    background-color:#CF0;
    min-height:80px;
}
#add_title
{
    padding-left:0px;
    height:40px;
}
#textarea
{
    padding-left:30px;
}
#post_time
{
    font-size:9px;
    float:left;
    width:580px;
    padding-top:0px;
}
#post_title
{
    float:left;
    font-size:12px;
    width:580px;
}
#post_content
{
    float:left;
    width:580px;
}    
#post_edit
{
    font-size:14px;
    text-align:right;
    margin-right:5px;
}

ログアウトしたページのソース:

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />


<LINK REL=StyleSheet HREF="style.css" TYPE="text/css" MEDIA=screen>


<title>Home - Chris's Blog</title>
</head>

<body>

<div id="universe">




<h1>Chris's Blog</h1>


<div id="content">

    <div id="menu">
                 The current server timezone is: Europe/London<p>&nbsp;</p>
  </div>
    <div id="subcontent">

        <div id="posts">



<div class="post">
    <div id="post_title">
        <h2><a href="index.php?id=8">Test</a></h2>
            <p>Posted on 06-12-2012 02:15:13 in <a href="category.php?id=3">Test</a> ip:            </p>

    </div>


    <div id="post_content">

jswqwjsiwqjs qw</div>

    </div>

<div class="post">
    <div id="post_title">
        <h2><a href="index.php?id=7">Ok Ok.</a></h2>
            <p>Posted on 01-01-1970 01:00:00 in <a href="category.php?id=3">Test</a> ip:            </p>

    </div>


    <div id="post_content">

Ok try # worked, lets see this one...here goes</div>

    </div>

<div class="post">
    <div id="post_title">
        <h2><a href="index.php?id=6">Try NUMBAH TREE</a></h2>
            <p>Posted on 06-12-2012 02:09:24 in <a href="category.php?id=3">Test</a> ip:            </p>

    </div>


    <div id="post_content">

Lets see if this oen works....</div>

    </div>

<div class="post">
    <div id="post_title">
        <h2><a href="index.php?id=5">Try #2</a></h2>
            <p>Posted on 12-06-2012 12:18:45 in <a href="category.php?id=3">Test</a> ip:            </p>

    </div>


    <div id="post_content">

Lets try this time if it works.</div>

    </div>

<div class="post">
    <div id="post_title">
        <h2><a href="index.php?id=1">Test added from Database</a></h2>
            <p>Posted on 11-06-2012 02:32:24 in <a href="category.php?id=3">Test</a> ip:            </p>

    </div>


    <div id="post_content">

This post was added from database, hope this shows on the website, would be pretty cool imo.</div>

    </div>
            </div>

        <div id="rightbar">
        <ul>
            <li><a href="index.php">Home</a></li>
                            <li><a href="index.php">Contact</a></li>
            <li><a href="login.php">Login</a></li>            </ul>
        </div>

    </div>

</div>

    </body>
    </html>
4

1 に答える 1

2

CSS から削除しfloat: left;ます。#post_content投稿の高さが 0 ピクセルになっています。

于 2012-06-12T20:36:35.477 に答える