EchoFool Posted May 25, 2010 Share Posted May 25, 2010 Hey I have a DIV with and ID and a style but it doesn't seem to execute the style if i have an ID with it. I use the ID to set the width and border and div position then the style to alternae the background color in a while loop but it doesn't work =/ #forumbody{ margin-left: auto; margin-right: auto; width: 90%; border: 1px solid #000000; } <?php $var = 0; While($var != 5){ if (!isset($i)) { $bg = '#000000'; $i = 1; } else { $bg = '#ffffff'; unset($i); } ?> <div style="background-color:<?php echo $bg;?>;" id="forumbody"> Test</div> <?php $var = $var + 1; } ?> Any one see why its not working ? Quote Link to comment https://forums.phpfreaks.com/topic/202786-div-id-cancels-out-style/ Share on other sites More sharing options...
premiso Posted May 25, 2010 Share Posted May 25, 2010 The style being set hardcoded via the styletag should override anything. Try on a different browser, see if it is a browser issue. Post the the View-Source of the page, to make sure that the alternating script works like it is suppose to. Quote Link to comment https://forums.phpfreaks.com/topic/202786-div-id-cancels-out-style/#findComment-1062833 Share on other sites More sharing options...
ram4nd Posted June 4, 2010 Share Posted June 4, 2010 There is another thing, you should have unique id's per page. Quote Link to comment https://forums.phpfreaks.com/topic/202786-div-id-cancels-out-style/#findComment-1067838 Share on other sites More sharing options...
haku Posted June 5, 2010 Share Posted June 5, 2010 Please don't post PHP in the HTML or CSS help sections of the forum. Only the HTML output of the php script is relevant, so please post the HTML output. Quote Link to comment https://forums.phpfreaks.com/topic/202786-div-id-cancels-out-style/#findComment-1068042 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.