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 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题