回声<样式></样式>在 php 中

如果我的条件匹配,我需要应用一些样式。我有如下风格


<style>

.adminCog {

    z-index: 3;

    position: absolute;

    right: 11px;

    top: 8px;

    display:none;   

}

</style>

仅当 user_id 为 1 时,我才要应用此项


就像,我试过了


<?php

if($user_id ==1){

echo '<style>

.adminCog {

    z-index: 3;

    position: absolute;

    right: 11px;

    top: 8px;

    display:none;   

}

</style>';

}

但它不起作用,没有给出任何错误,让我知道,如果有人可以纠正我。谢谢!


茅侃侃
浏览 78回答 1
1回答

蝴蝶不菲

像这样尝试注意:检查您在$user_id中得到了什么。<?php&nbsp; &nbsp; if($user_id ==1){?><style>&nbsp; &nbsp;.adminCog {&nbsp; &nbsp; &nbsp; &nbsp;z-index: 3;&nbsp; &nbsp; &nbsp; &nbsp;position: absolute;&nbsp; &nbsp; &nbsp; &nbsp;right: 11px;&nbsp; &nbsp; &nbsp; &nbsp;top: 8px;&nbsp; &nbsp; &nbsp; &nbsp;display:none;&nbsp; &nbsp;&nbsp; &nbsp;}&nbsp;</style>&nbsp;<?php&nbsp; &nbsp;}&nbsp;?>
打开App,查看更多内容
随时随地看视频慕课网APP