doudun5009 2011-02-01 08:02
浏览 39
已采纳

PHP,HTML和CSS的页面布局问题

For some reason my CSS is not formatting my div tags into the correct spots on the page. It works on all my other pages but this one has a lot more PHP in it than normal and I am wondering if that is the problem. Page

<!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php
    require("protect/serverInfo.php");
    $myusername=$_POST[Email]; 
    $mypassword=$_POST[Password];
    $result = mysql_query("SELECT * FROM Customers WHERE Email='$myusername' AND Password=$mypassword");
    $count=mysql_num_rows($result);
    if($count==1){
        while($row = mysql_fetch_array($result)){
        ?>
        <div class="wrapper">
            <div class="customerHead">';
                <h1>  
                    <?php echo $row['Customer'] ?> 
                </h1>
            </div>
            <div class="customerInfoMain">
                 Company: <?php echo $row['Company'] ?><br />
                  State: <?php echo $row['State'] ?>
            </div>  
            <div class="customerCards">';
                 <a href ="something/<?php echo $row['imagePathFront'] ?>" target="_blank"><img src="<?php echo $row['imagePathFront'] ?>" width="400px" height="303px" align="center" alt="" /></a>
                 <a href ="something/<?php echo $row['imagePathBack'] ?>" target="_blank"><img src="<?php echo $row['imagePathBack'] ?>" width="400px" height="303px" align="center" alt="" /></a>
            </div>  
            <div class="customerComments">';
                <h5>Changes Made:</h5><br /> <?php echo $row['Comments'] ?> 
            </div>
        </div>
    <?php   
        }
    }
    else {
        echo "Wrong Username or Password";
    }
?>

</body>

</html

>

CSS

.customerCards{
    top: 150px;
    position: relative;
    width: 425px;
    border: 3px;
    border-style:solid;
    border-color: black;
    background-color: silver;
    z-index:1;
}
.customerInfoMain{
    top: 200px;
    position: relative;
    width: 200px;
    left: 520px;
    border: 3px;
    border-style:solid;
    border-color: black;
    background-color: silver;
    z-index:2;
}
.customerComments{
    position: relative;
    width: 200px;
    left: 580px;
    border: 3px;
    border-style:solid;
    border-color: black;
    background-color: silver;
    z-index:2;
}

.wrapper{
    position: absolute;
    left: 50%;
    width: 900px;
    margin-left: -475px;
}

Source after page load

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

<title>Untitled 1</title>

<link href="stylesheet.css" rel="stylesheet" type="text/css" />

</head>



<body>

Wrong Username or Password

</body>



</html>
  • 写回答

2条回答 默认 最新

  • douying7289 2011-02-01 08:13
    关注

    its because your wrapper just starting if there is user.. But what happend if you put your wrapper around the PHP, like:

    <!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 content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 1</title>
    <link href="stylesheet.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <div class="wrapper">
            <?php
            require("protect/serverInfo.php");
            $myusername=$_POST[Email]; 
            $mypassword=$_POST[Password];
            $result = mysql_query("SELECT * FROM Customers WHERE Email='$myusername' AND Password=$mypassword");
            $count=mysql_num_rows($result);
            if($count==1){
                while($row = mysql_fetch_array($result)){
                ?>
    
                    <div class="customerHead">';
                        <h1>  
                            <?php echo $row['Customer'] ?> 
                        </h1>
                    </div>
                    <div class="customerInfoMain">
                         Company: <?php echo $row['Company'] ?><br />
                          State: <?php echo $row['State'] ?>
                    </div>  
                    <div class="customerCards">';
                         <a href ="something/<?php echo $row['imagePathFront'] ?>" target="_blank"><img src="<?php echo $row['imagePathFront'] ?>" width="400px" height="303px" align="center" alt="" /></a>
                         <a href ="something/<?php echo $row['imagePathBack'] ?>" target="_blank"><img src="<?php echo $row['imagePathBack'] ?>" width="400px" height="303px" align="center" alt="" /></a>
                    </div>  
                    <div class="customerComments">';
                        <h5>Changes Made:</h5><br /> <?php echo $row['Comments'] ?> 
                    </div>
    
            <?php   
                }
            }
            else {
                echo "Wrong Username or Password";
            }
            ?>
        </div>
    </body>
    </html>
    

    "Then you should have a little bit of the CSS action?"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题