I need to modify some CSS styles according to a condition in PHP, so I looked it up, and from what I saw it is necessary to include a header in the CSS file and change the file .css
to .php
, or create a file htacess (but where? where?) ... but I think because they are old, these articles are outdated with some (or all, or none: D) versions of PHP, CSS, Apache or Bootstrap I'm using, or most likely, that it's just me doing something wrong.
The case is that I mounted these panels with nav-tabs
of Bootstrap:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="row">
<div class="col-md-4">
<div class="panel panel-success">
<div class="panel-heading" align="center">
<label class="btn" id="cdom">
<i class="glyphicon glyphicon-ok">
</i> Título</label></div>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#sectionA">Resumo</a></li>
<li><a data-toggle="tab" href="#sectionB">Entenda</a></li>
</ul>
<div class="tab-content">
<div id="sectionA" class="tab-pane fade in active">
Seção A
</div>
<div id="sectionB" class="tab-pane fade">
<h5>Section B</h5>
</div>
</div>
</div>
</div> <div class="col-md-8></div>
</div>
</div>
<div class="col-md-2"></div>
</div>
And I've already been able to change the color of panel-header
by escaping HTML, according to one condition.
<div class="panel <?php if ($var1 > 60000){echo 'panel-success';}else {echo 'panel-danger';}?> bs-example" align="center">
But now I need to change the CSS of nav-tab
, too, according to the same condition. I already tried to span
, but it did not work. I already changed the name of the CSS file, it includes header
and I called the .php
where the variable is, but it still did not work.
The current CSS style.php
:
<?php header('Content-type:text/css');
include "../saida.php";
?>
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus {
color: #020202;
cursor: default;
background-color: <?php if ($var1 > 60000){echo '#0e7363';}else {echo '#f2dede';}?> ;
border-bottom-color: transparent;
}
But it still does not change the color according to the condition.
The question
How to include PHP script in the CSS file, without having to change to .php
, ie using htacess
or equivalent, and how to include PHP within CSS is the correct way I'm doing?)?