Skip to content

Flips css direction from ltr to rtl (or rtl to ltr)

License

Notifications You must be signed in to change notification settings

penobit/css-flip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSS Flip

Build Status Latest Stable Version Total Downloads Downloads Month Petreon donation PayPal donation

Flip css/scss direction from ltr to rtl or rtl to ltr with single line php code!


Installation

Install this package via Composer.

composer require penobit/css-flip

You can also download latest release from Github and include src/CSSFlip.php manually but i recommend using composer to stay up to date and easier install and usage

Usage

Create CSSFlip object

use Penobit\CSSFlip\CSSFlip;

$cssFlip = new CSSFlip();
$cssCode = <<<CSS
body{
  direction: ltr;
}
div{
  text-align:left;
  margin-left: 20px;
  margin-right: 2rem;
}
span{
  padding: 10px 15px 20px 25px;
}
CSS;

$flippedCssCode = $cssFlip->transform($cssCode);

/* 
# Output of above code will be
body{
  direction: rtl;
}
div{
  text-align:right;
  margin-right: 20px;
  margin-left: 2rem;
}
span{
  padding: 10px 15px 20px 25px;
  padding: 10px 25px 20px 15px;
}
*/