title: change css dynamically if condition in PHP
body: <p>I'm using a wordpress theme and I do want to change the css of 2 blocks using php when the value of certain variable is even or odd..</p>
  
  <p>this is my code : </p>
  
  <pre><code>&lt;?php 
              $i = 0;
              while ( have_posts() ) {
  
                  // Override
                  if(($i % 2) == 1) { ?&gt;
  
                      &lt;style type="text/css"&gt;
                          .grid-box-img {
                              width: 54%;
                              float: left;
                          }
  
                          .entry-head {
                              width: 56%;
                              background-color: #fff;
                              position: absolute;
                              z-index: 10;
                              margin-left: 43%;
                              margin-top: 27%;
                          }
                      &lt;/style&gt;
                      &lt;?php 
                  }
                  else { ?&gt;
                      &lt;style type="text/css"&gt;
                          .grid-box-img {
                              width: 54%;
                              float: right;
                          }
  
                          .entry-head {
                              width: 56%;
                              background-color: #fff;
                              position: absolute;
                              z-index: 10;
                              margin-top: 27%;
                          }
                      &lt;/style&gt;
                      &lt;?php
                  } 
                  $i++;
                  the_post(); 
              } ?&gt;
  </code></pre>
  
  <p>But, unfortunately it doesn't work... It applies only the CSS of the last value.</p>
  
  <p>How can I do that ? Thank you :)</p>