Hiding a Div using php

后端 未结 6 404
失恋的感觉
失恋的感觉 2020-12-18 05:47

I am currently hiding a div based on an if statement. The method I use is, use echo out a css style of display: none

Here is w

6条回答
  •  臣服心动
    2020-12-18 06:02

    I generally try to avoid using PHP Conditionals inside of CSS; especially inline CSS (CSS that is on the same page).

    I would keep your CSS in its own CSS file and use the PHP conditional to either add a "hide" class to the DIV -OR- not echo the DIV at all.

    
    
        
    class="hide"> Foo bar

    or alternatively

    
    
    
    
    
        
    Foo bar

    or

    
    
    
        
        
    Foo bar

    Many times the div needs to be outputted so it can be re-displayed using JavaScript (e.g. carousels, sliders, etc.)

提交回复
热议问题