0

I have one block of code as below

<div class="col-md-5 col-xs-12">
<?php echo "Current bootstrap class name is".$class_name;?>
</div>

$class_name should return col-md-5 in laptop and col-xs-12 in mobile.

So anybody know how to achieve this?

Pravin
  • 37
  • 1
  • 12

1 Answers1

0

You cannot fetch css class names with PHP, because HTML is generated only after PHP has finished its job. You'll have to use js/jquery for this. the code depends on which "tag" you want to start from.

Rahul M
  • 1,498
  • 12
  • 19
  • Thanks..Actually I wants to change div class position according to screen size. eg. I have col-1 col-2 col-3 this is my Laptop view then want to show something like col-1 col-3 col-2 – Pravin Jun 16 '16 at 06:52
  • 1
    To deal with different screen sizes, as you might already know, bootstrap provides a number of classes, like col-lg-* for large screens, col-md-* from medium & col-sm-* and col-xs-* from even smaller screens. Then there are a few helper classes as well.. like: hidden-md-up will hide the column on large screen sizes OR hidden-sm-down will hide the column on smaller screens.. I think pretty much anything can be managed in context of positioning & visibility of content using bootstrap. – Rahul M Jun 16 '16 at 06:57
  • @RahulM is correct. You need to edit your answer to reflect two solutions: bootstrap classes and JavaScript. – Ian Jun 16 '16 at 07:47