我有一个menu.php,menu.php中定义了左右页面都有的导航菜单部分,即head标签对和body标签都在menu.php中,head标签对之间使用了一个外部样式表style1.css,其他php都require了menu.php。
例如customer.php中require了menu.php,custom.php中不属性menu.php中的那些元素的stype只能使用内联样式表吗?还是可以定义style1.css中?
我在customer.php为html标签定义了class属性,在style1.css中对这个class设置了css属性,结果不起作用。应该起作用吗?

解决方案 »

  1.   

    至少你没有说清楚你遇到的问题,style有继承关系,这是大家都知道的
      

  2.   

    基本上是下面这样:
    style1.css
    .formrow{
         margin:2px;
         padding:2px;
         color:gray;
    }menu.php
    <head>
    <title>Hotel management System</title>
    <link type="text/css" rel="stylesheet" href="/css/style1.css">
    </head>
    <body style="position: relative;min-height: 100%; top:0px; background: url('/res/img1.png') repeat-x; color:#000000;margin:0 auto;">
    <div style="position: relative; width:100%; margin:0 auto;">
    ......
    custom.php
    <?php require("../menu.php");?>
    <div class="content" style="clear:both; min-height:500px; margin:0 auto;margin-left:200px;position:absolute;top:90px;width:920px;min-height:500px;z-index:-1;border:solid 1px red;">
            <div style="width:600px; float:left;border:solid 1px blue;">     
                <?php
                    echo "<div class='formrow'>Certificate type:<select id='idcardtype$i'   name='idcardtype$i'>";
                        echo "<option value='idcard'>id card</option>";
                        echo "<option value='passport'>passport</option>";
                        echo "</select>";
                    echo "</div>";
                ?>
            </div> 
    </div>
    </div>
    </body>       
      

  3.   

    按理应该起作用。
    我想你应该检查样式表是否被加载,href是否正确。如果你用chrome浏览器的话,审查元素功能可以帮你看到<div class='formrow'> 的所有style属性