Hello!
In the first place, i’m sorry if my question mathes the previous one, they are quite similar. I try to adapt the answer from the previous question for my problem but it didn’t work.
So here is the thing.
I want to conditionally display a div so when there are no values, the div is not displayed. Without the php if part, all is working fine, the css styles are applying to the divs. But when i add the if condition, the CSS doesn’t apply anymore.
Here is the div part:
[CODE]<?php
$getCar_1 = getCar_1();
$getCar_2 = getCar_2();
if(!empty($getCar_1) || !empty($getCar_2)){
?>
<div class=”block”>
<div class=”up”>
<div class=”title”><h4>Cars</h4></div>
</div>
<div class=”down”>
<div class=”column_1″><b><?php getCar_1(); ?></b></div>
<div class=”column_2″><b><?php getCar_2(); ?></b></div>
</div>
</div>
<?php
}
?>
and here is the CSS:
[CODE].block{
width:900px;
margin:0 auto;
overflow:hidden;
float:left;
}
.up{
width:100%;
text-align:center;
border:1px solid;
margin-top:10px;
margin-bottom:10px;
background-color:skyblue;
}
.down{
width:100%;
clear:both;
}
.column_1{
float:left;
width:47%;
padding:10px;
}
.column_2{
float:right;
width:47%;
text-align:right;
padding:10px;
}
If i use only this code:
[CODE]<div class=”block”>
<div class=”up”>
<div class=”title”><h4>Cars</h4></div>
</div>
<div class=”down”>
<div class=”column_1″><b><?php getCar_1(); ?></b></div>
<div class=”column_2″><b><?php getCar_2(); ?></b></div>
</div>
</div>
it displays normal. Here is a picture:
[URL=”https://i.stack.imgur.com/fj1RH.jpg”]https://i.stack.imgur.com/fj1RH.jpg
And when adding the php if part it displays this:
[URL=”https://i.stack.imgur.com/dMPUY.jpg”]https://i.stack.imgur.com/dMPUY.jpg
So when i add the php if, the css has no effect anymore. I tried many variants but did not find the solution.