Manage css via php

im start work on a new LAMP project.

in general, all the css classes that I do, especially for the layout, look like this:

.pageBoundaries{
   width:999px;
   margin:auto;
}

.onethird{
   width:333px;
   float:left;
   display:block;
}

.twothird{
   width:666px;
   float:left;
   display:block;
}

.half{
   width:499px;
   float:left;
   display:block;
}

Now I thought that I was making a php file to manage things like width (maybe color, borders, etc.). as:

$pageWidth=999;


.pageBoundaries{
       width:<?php $pageWidth ?>px;
       margin:auto;
    }

    .onethird{
       width:<?php $pageWidth/3 ?>px;
       float:left;
       display:block;
    }

    .twothird{
       width:<?php ($pageWidth*2)/3 ?>px;
       float:left;
       display:block;
    }

    .half{
       width:<?php $pageWidth/2 ?>px;
       float:left;
       display:block;
    }

and then I can set the headers from this php file so that the browser interprets it as a css file. any ideas on this scheme? its pros and cons?

By doing this, I think creating colorful themes would also be pretty easy.

+3
source share
6 answers

Looks like just make sure you send all the necessary HTTP headers for caching so that browsers don't load your CSS files for every request.

SASS LESS. , ( ). , CSS. , , ( ), , mixins, .. SASS, , .

+2

* fine.

, .

CSS, , , HTML-, .

* , PHP , , . PHP script.

+1

, , , . CSS PHP , .

:

• . , CSS , . / , .

• , PHP . , ? (, javascript PHP , )

CSS PHP:

• CSS , PHP. (, , )

CSS PHP:

• CSS . (, / - )

Alternative

javascript . , jQuery, CSS, , .

CSS:

SASS/SCSS LESS . .. CSS.

+1

css php . , , php , , script html, js css

0

, , , LESS

0

:

Cons: you must stop the client browser from caching in order to get dynamic content, but if you do this, the CSS file will be loaded for each request, it will take more time to load each page for the client

0
source

Source: https://habr.com/ru/post/1782741/


All Articles