How to apply different width stored in PHP to 3 identical DIVs (using same CSS) -


i have graph has css styling. it's width set in wordpress, need use php apply it.

at first have applied width adding inline css in html. worked for few graphs on 1 page. when wanted add responsivness occured inline css overwriting mediaquries , breaking responsivness. decided applying php variables directly css in way described here:

http://css-tricks.com/css-variables-with-php/

the problem when following situation happens:

i have rule:

.graph {     width: <?php echo $graph-width; ?>;        } 

i have 3 graphs on 1 page using class. each graph has different width specified in wordpress admin panel.

how apply different widths stored in php 3 graphs on page.

please note never know how many graphs on 1 page.

i don't have time test here's approach might work. have divs created class contains incrementing numbers, ie. container-1, container-2, container-n.

then jquery this:

var = 1; function widthadder() {     if(i % 2 === 0) { //this every second element          $('.container-' + i).css(width: "100px"); //here set width          i++;     } else if (i % 3 === 0) { // every third          $('.container-' + i).css(width: "150px"); //here set width          i++;     } else { //this every first          $('.container-' + i).css(width: "200px"); //here set width          i++;     } }  widthadder(); 

hope helps.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -