Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何显示我的";酒吧;页面顶部的div?_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 如何显示我的";酒吧;页面顶部的div?

Javascript 如何显示我的";酒吧;页面顶部的div?,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我创建了一个校长选举系统 但是我想通过设计我的网站来改进用户界面 在我的管理员视图中,有许多代码需要显示,因此有时我需要向下滚动 这是我为administrator.php编写的代码,我有一个名为“header”的header divice 我想,即使我向下滚动,这个“标题”也会留在我身边 如果你想在你的浏览器上尝试所有文件,我可以上传到互联网上;只是评论一下 <?php require_once('admin-auth.php'); ?> <!DOCTYPE html

我创建了一个校长选举系统

但是我想通过设计我的网站来改进用户界面

在我的管理员视图中,有许多代码需要显示,因此有时我需要向下滚动

这是我为administrator.php编写的代码,我有一个名为“header”的header divice

我想,即使我向下滚动,这个“标题”也会留在我身边

如果你想在你的浏览器上尝试所有文件,我可以上传到互联网上;只是评论一下

<?php
    require_once('admin-auth.php');
?>
<!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="css/style.css" type="text/css" media="screen"/>
        <link rel="SHORTCUT ICON" href="images/log.png">
        <title>DSI Voting System</title>
        <style>
            #tbl
            {
                font-family: Tahoma, Geneva, sans-serif;
                border-collapse: collapse;
                margin-bottom: 20px;
                width: 885px;
            }
            #tbl td, #tbl th
            {
                font-size: 11px;
                border: 1px solid #094f4b;
                padding: 3px 7px 2px 7px;
                background-color: #ffffff;
                color: #4b4b4b;
                font-family: Tahoma, Geneva, sans-serif;
            }
            #tbl th
            {
                font-size: 14px;
                text-align: left;
                padding-top: 5px;
                padding-bottom: 4px;
                background-color: #116763;
                color: #ffffff;
            }
        </style>
    </head>

    <body>
        <div id="header">
            <div id="bar">
                <div style="width:900px; margin:auto; padding-top:8px;">
                    <img src="img/aclc-logo.png" /></div>
                </div>
                <div id="subbar">
                    <table style="padding-top:80px; width:890px; margin:auto; text-align:right;">
                        <tr>
                        <td id="bold" style="color:#FFF; padding-left:10px;">
                        <a href="administrator.php">Passcodes</a> | <a href="generating.php">Election Results</a> | <a href="print.php">Save/Print</a> | <a href="admin-logout.php">Logout</a>
                        </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div id="content">
                <center>
                    <div id="scroll">
                        <table style="margin-top:0px;">
                            <tr>
                                <td colspan="2" style="font-family:Tahoma, Geneva, sans-serif; font-size:16px; padding-bottom:10px;"><b>ADMINISTRATOR</b></td>
                            </tr>
                            <tr>
                                <td colspan="2" style="font-family:Tahoma, Geneva, sans-serif; font-size:11px; color:#116763;"><a href="registered.php"><b style="color:#116763;">Generate New Passcode</b></a></td></tr>

                            <tr>
                                <td colspan="2" style="font-family:Tahoma, Geneva, sans-serif; font-size:11px; color:#116763;"><a href="registerednumber.php"><b style="color:#116763;">Generate New 5 Passcodes at once</b></a></td></tr>

                            <tr>
                                <td colspan="2" style="font-family:Tahoma, Geneva, sans-serif; font-size:11px; color:#116763;"><a href="registerednumber2.php"><b style="color:#116763;">Generate New 10 Passcodes at once</b></a></td></tr>

                            <tr>
                                <td colspan="2">
                                    <?php

                                        // Databse connection
                                        include_once 'config.php';

                                        // Connect to MySQL server
                                        $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
                                        if(!$link) {
                                            die('Failed to connect to server: ' . mysql_error());
                                        }

                                        // Select database
                                        $db = mysql_select_db(DB_DATABASE);
                                        if(!$db) {
                                            die("Unable to select database");
                                        }

                                        // Create query
                                        $row="SELECT * FROM registered";
                                        $result=mysql_query($row);

                                        echo "<table id='tbl'>
                                        <tr>
                                            <th width='60'>Number</th>
                                            <th>Generated Password</th>
                                            <th>Full Name</th>
                                            <th>Signature</th>
                                        </tr>";

                                        while($row = mysql_fetch_array($result))
                                        {
                                            echo "<tr>";
                                            echo "<td><b>" . $row['id'] . "</b></td>";
                                            echo "<td><b style='color:red;'>" . $row['voters'] . "</b></td>";
                                            echo "<td><b style='color:red;'></b></td>";
                                            echo "<td><b style='color:red;'></b></td>";
                                            echo "</tr>";
                                        }
                                        echo "</table>";
                                        mysql_close($link);
                                    ?>
                                </td>
                            </tr>
                        </table>
                    </div>
                </center>
            </div>
            <div id="footer">
            Ozan Kurt Voting System &copy; 2014
        </div>
    </body>
</html>

这很简单-只需添加位置:固定和顶部0px到您的元素。大概是这样的:

#bar
{
    background-image:url(../images/feln-crowd.png);
    height:80px;
    width:100%;
    -moz-box-shadow:0px 0px 1px #005073;
    -webkit-box-shadow:0px 0px 1px #005073; 
    box-shadow:0px 0px 1px #005073;
    padding:0px;
    border-bottom:1px solid #0c0d0a;
    position: fixed;
    top: 0px;
}
尝试添加:

position: fixed;
这将确保它保持在您站点的同一位置

然后您可以使用

top: 0px;

例如,要将其定位在正确的位置

我按照您所说的方式编辑了代码,但现在我遇到了一个新问题。该分区下的文本现在位于该标题下。我看不见他们。我自己解决了:)泰。
top: 0px;