dougan4884 2017-04-05 17:24
浏览 53
已采纳

在页面顶部回显字符串时表格样式更改

EDIT

This is not a great question by any means; it was really just a fluke that I discovered it and rather than delete this question I will leave it up for posterity.

END - EDIT

I'm not really sure how to search for this, but I came across it while styling my table and it's very odd. I am outputting data in PHP and populating it in a table. If I echo a string at the top of the page, the formatting of the table changes - it actually looks better - but I can't figure out why it's happening. I am using Twitter Bootstrap and PHP 7.

Here is the table:

Normal Table

And here is what it looks like when I echo a string at the top of the page:

Table Looks Different

I can't imagine what effect echoing a string is causing on the table styling, but the table looks better, in my opinion, when I am echoing a string. So I really have 2 questions:

  1. Why is this effect occurring?
  2. How can I achieve this effect without echoing a string on the page?

EDIT

Output HTML Before:

<html lang="en"><head>
        <meta charset="UTF-8">
        <title>Title</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <link rel="stylesheet" type="text/css" href="css/style.css"><!--Personalized stylesheet-->
        <script type="text/javascript" src="js/jquery-3.1.1.js"></script>
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <body>
        <div id="message">
                        <span id="stats"></span>
        </div>

        <nav class="navbar navbar-inverse">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <p id="logo" class="navbar-brand"><img src="images/logo_circle.png">&nbsp;Page Title</p>
                </div>
                <div id="navbar" class="navbar-collapse collapse">
                    <ul class="nav navbar-nav navbar-right">
                        <li class=""><a href="#n">Problems or Suggestions?</a></li>
                        <li>
                            <p class="navbar-btn">
                                <a href="mailto:myname@email.com?subject=;body=Please enter your comments here:Please include a screenshot if you have run into an error:" target="_top" class="btn btn-info">E-Mail Support</a>
                            </p>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
        <div class="container">
            <form class="form-inline" name="search_records" method="POST" action="">
                <div class="form-group">
                    <label for="active">Active? </label>
                    <select name="active">
                        <option value="Y">Yes</option>
                        <option value="N">No</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="sort">Sort By: </label>
                    <select name="sort">
                        <option value="Effective_Date">Effective Date</option>
                        <option value="MinMargin">Min Margin</option>
                        <option value="MaxMargin">Max Margin</option>
                        <option value="Commission_Percent">Commission Percent</option>
                        <option value="AOPGoal">AOP Goal</option>
                        <option value="Last_Modified">Last Modified</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="order">Order: </label>
                    <select name="order">
                        <option value="ASC">Ascending</option>
                        <option value="DESC">Descending</option>
                    </select>
                </div>
                <button type="submit" class="btn btn-default" name="submit_search_records">Search</button>
            </form>
            <div class="row clearfix center">
                <h2>Active Records</h2>           
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                        <tr>
                            <th>Effective_Date</th>
                            <th>Min Margin</th>
                            <th>Max Margin</th>
                            <th>Commission Percent</th>
                            <th>Year</th>
                            <th>Month</th>
                            <th>AOP Goal</th>
                            <th>Last Modified</th>
                            <th>Modified By</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                <input type="hidden" value="2">
                <td>2017-04-05</td>
                <td>60100</td>
                <td>126000</td>
                <td>.030%</td>
                <td>2017</td>
                <td>April    </td>
                <td>26000</td>
                <td>2017-04-05 10:49:57</td>
                <td>localhost\DEV</td>
            </tr><tr>
                <input type="hidden" value="3">
                <td>2017-04-05</td>
                <td>60100</td>
                <td>126000</td>
                <td>.030%</td>
                <td>2017</td>
                <td>April    </td>
                <td>26000</td>
                <td>2017-04-05 10:50:00</td>
                <td>localhost\DEV</td>
            </tr><tr>
                <input type="hidden" value="4">
                <td>2017-04-05</td>
                <td>60100</td>
                <td>126000</td>
                <td>.030%</td>
                <td>2017</td>
                <td>April    </td>
                <td>26000</td>
                <td>2017-04-05 10:50:06</td>
                <td>localhost\DEV</td>
            </tr>                    </tbody>
                </table>

                <div class="spacer"></div>

            </div>
            <div class="spacer"></div>

        </div>

</body></html>

Output HTML After:

<html lang="en"><head></head><body>Table looks better
        <meta charset="UTF-8">
        <title>Title</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <link rel="stylesheet" type="text/css" href="css/style.css"><!--Personalized stylesheet-->
        <script type="text/javascript" src="js/jquery-3.1.1.js"></script>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <div id="message">
                        <span id="stats"></span>
        </div>

        <nav class="navbar navbar-inverse">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <p id="logo" class="navbar-brand"><img src="images/logo_circle.png" >&nbsp;Page Title</p>
                </div>
                <div id="navbar" class="navbar-collapse collapse">
                    <ul class="nav navbar-nav navbar-right">
                        <li class=""><a href="#n">Problems or Suggestions?</a></li>
                        <li>
                            <p class="navbar-btn">
                                <a href="mailto:myname@email.com?subject=;body=Please enter your comments here:Please include a screenshot if you have run into an error:" target="_top" class="btn btn-info">E-Mail Support</a>
                            </p>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>
        <div class="container">
            <form class="form-inline" name="search_records" method="POST" action="">
                <div class="form-group">
                    <label for="active">Active? </label>
                    <select name="active">
                        <option value="Y">Yes</option>
                        <option value="N">No</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="sort">Sort By: </label>
                    <select name="sort">
                        <option value="Effective_Date">Effective Date</option>
                        <option value="MinMargin">Min Margin</option>
                        <option value="MaxMargin">Max Margin</option>
                        <option value="Commission_Percent">Commission Percent</option>
                        <option value="AOPGoal">AOP Goal</option>
                        <option value="Last_Modified">Last Modified</option>
                    </select>
                </div>
                <div class="form-group">
                    <label for="order">Order: </label>
                    <select name="order">
                        <option value="ASC">Ascending</option>
                        <option value="DESC">Descending</option>
                    </select>
                </div>
                <button type="submit" class="btn btn-default" name="submit_search_records">Search</button>
            </form>
            <div class="row clearfix center">
                <h2>Active Records</h2>           
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                        <tr>
                            <th>Effective_Date</th>
                            <th>Min Margin</th>
                            <th>Max Margin</th>
                            <th>Commission Percent</th>
                            <th>Year</th>
                            <th>Month</th>
                            <th>AOP Goal</th>
                            <th>Last Modified</th>
                            <th>Modified By</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                <input type="hidden" value="2">
                <td>2017-04-05</td>
                <td>60100</td>
                <td>126000</td>
                <td>.030%</td>
                <td>2017</td>
                <td>April    </td>
                <td>26000</td>
                <td>2017-04-05 10:49:57</td>
                <td>localhost\DEV</td>
            </tr><tr>
                <input type="hidden" value="3">
                <td>2017-04-05</td>
                <td>60100</td>
                <td>126000</td>
                <td>.030%</td>
                <td>2017</td>
                <td>April    </td>
                <td>26000</td>
                <td>2017-04-05 10:50:00</td>
                <td>localhost\DEV</td>
            </tr><tr>
                <input type="hidden" value="4">
                <td>2017-04-05</td>
                <td>60100</td>
                <td>126000</td>
                <td>.030%</td>
                <td>2017</td>
                <td>April    </td>
                <td>26000</td>
                <td>2017-04-05 10:50:06</td>
                <td>localhost\DEV</td>
            </tr>                    </tbody>
                </table>

                <div class="spacer"></div>

            </div>
            <div class="spacer"></div>

        </div>

</body></html>
  • 写回答

1条回答 默认 最新

  • doufan6886 2017-04-06 19:07
    关注

    As was pointed out by LGSon, the head elements (title, link, etc) were being rendered in the body tags whenever I echoed a string. This was altering the linked css stylesheets and changing up the formatting of my table seen in the above screenshots. I have personalized stylesheets besides using Twitter Bootstrap that are altering my table differently.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀