Jump to content

if statement help


MDanz

Recommended Posts

i have a div called layer1, which is either visible or hidden depending on some javascript.  In php how do i do...

 

if (div layer1 is visible) {} else {}

 

or

 

if (div layer1 is not hidden) {} else {}

 

 

this is the css code when it is hidden, i can't have it if(div layer1 is hidden) because that would mess up my code.

 

#layer1 {
display:none; 
      position:fixed;
  color:#FFFFFF; 
  width: 400px;
      border: 1px solid #FBB917; 
      background-color: black; 
      padding: 5px;
   
   

}

Link to comment
https://forums.phpfreaks.com/topic/194116-if-statement-help/
Share on other sites

thanks can you help me with this..

 

 

how do i use php variable in a css stylesheet?

 

i have the variable $w,  i want to use that in a css stylesheet.

You can't. Php can only be used in PHP files. What you could do is not make a separate style sheet, but <style> tags in a php file and then it could be changed by a variable.

 

But I don't know why you're even looking at PHP. What you need is to manipulate styles of objects. That's what JavaScript does best and it's very simple to do so.

Link to comment
https://forums.phpfreaks.com/topic/194116-if-statement-help/#findComment-1021354
Share on other sites

That's not entirely true. You CAN use PHP in CSS as you generate it (meaning you don't have a static .css file) but it does not sound like that is what you want to do in this case. I suppose all you want to do is toggle the display depending on what the user does? Then you should simply use javascript.

Link to comment
https://forums.phpfreaks.com/topic/194116-if-statement-help/#findComment-1021359
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.