vendredi 18 novembre 2016

CSS not applying to div when adding PHP condition

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:

<?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 part:

.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;
}

I know this code is very simple but i can't understand why it is not working properly.

Aucun commentaire:

Enregistrer un commentaire