我需要根据section_name更新css.如果部分是精选 css将是right:0,如果section_name是最新的css将是left:0如何我注入一块PHP到CSS?
<img src="square-009.jpg" style="width:300px; height:355px; position: fixed; z-index:9; right:0;" />
Run Code Online (Sandbox Code Playgroud)
section_name变量已经定义,它正在工作
<?php echo $section['section_name']; ?>
Run Code Online (Sandbox Code Playgroud)
小智 6
只需使用类:
.Featured {
width:300px;
height:355px;
position:fixed;
z-index:9;
right:0;
}
.Latest {
width:300px;
height:355px;
position:fixed;
z-index:9;
left:0;
}
Run Code Online (Sandbox Code Playgroud)
然后动态填充类:
<img src="square-009.jpg" class="<?php echo $section['section_name']; ?>" />
Run Code Online (Sandbox Code Playgroud)