显示div的问题

时间:2017-10-20 18:26:21

标签: php html css

我已将php页面(courses.php)包含到另一个php页面(course.php)中。 在course.php中包含courses.php后,我编写了一个div标签,希望它显示在以COURSES为标题的div旁边。

// Courses.php

    <html>
    <head>
        <style>
            #top
            {
                height: 100px;
                border :0.5px solid;
            }
            #left
            {
                height: 520px;
                width: 250px;
                border :0.5px solid;
            }
        </style>
    </head>

    <body>
        <div id = "top"></div>
        <div id = "left">
            <center>
                <h2><b> COURSES </h2></b>
                <ul>
                    <li><a href = "Html.html" target = "output"> HTML </a> 
               </li>
                    <li><a href = "C++.html" target = "output"> C++ </a> 
                </li>
                </ul>
            </center>
        </div>
    <body>
</html> 

Page for Courses.php

// course.php

    <html>
    <head>
        <style>
        #center
            {

                height: 530px;
                width: 900px;
                border :0.5px solid;
            }

        </style>
    </head>
    <body>

            <?php include("courses.php");?>

            <div id = "center">
            <h2>HEY</h2>
            </div>
    </body>
    </html>

page for Course.php

我希望显示HEY的div显示在显示COURSES的div旁边。 还建议如何将具有HEY的div标签垂直分成两半。

我试图显示彼此相邻的两个div的事情:

  1. 包括div中的包含php标记。
  2. 包括包含php标签(在div中)以及下一个div标签 父div标签。
  3. 然后用不同的方法操纵float和position属性 组合,但没有帮助。

1 个答案:

答案 0 :(得分:0)

你可以在Courses.php

中这样写
<style>
    #top
    {
        height: 100px;
        border :0.5px solid;
    }
    #left
    {
        height: 520px;
        width: 250px;
        border :0.5px solid;
    }
</style>

<div id = "top"></div>
<div id = "left">
    <center>
        <h2><b> COURSES </h2></b>
        <ul>
            <li><a href = "Html.html" target = "output"> HTML </a> 
       </li>
            <li><a href = "C++.html" target = "output"> C++ </a> 
        </li>
        </ul>
    </center>
</div>

允许body元素包含样式,但这不是一个好习惯,鼓励你分成两个文件,Courses.php和Courses_css.php,然后将它们导入到Course.php的正确位置

相关问题