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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.