Öğrencinin ortalama puanına göre harf puanını veren ayrıca aldığı nota göre CSS arkaplan rengini değiştiren örnek.

muho61

Paylaşım Ekibi
Üyelik Tarihi
23 Aralık 2020
Mesajlar
262
Beğeniler
2
Ticaret: 0 / 0 / 0
Kod:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
    .kutu{
        width: 150px;
        color: white;
        font-size: 30px;
        text-align: center;
    }
    .sonuca{
        background-color: green;
    }
    .sonucb{
        background-color:darkgoldenrod;
    }
    .sonucc{
        background-color: #5C3F08;
    }
    .sonucd{
        background-color: #7F2208;
    }
    .sonuce{
        background-color: #F90004;
    }
    .sonucf{
        background-color: #2D0001;
    }
    </style>
</head>
<body>
<?php
    $not=95;
    if($not>=85 && $not<=100){
        $not2="A";
        $renk="sonuca";
    }
    else if($not>=70 && $not<85){
        $not2="B";
        $renk="sonucb";
    }
    else if($not>=60 && $not<70){
        $not2="C";
        $renk="sonucc";
    }
    else if($not>=50 && $not<60){
        $not2="D";
        $renk="sonucd";
    }
    else if($not>=0 && $not<50){
        $not2="E";
        $renk="sonuce";
    }
    else{
        $not2="F";
        $renk="sonucf";
    }
?>
<div class="<?php
            echo("kutu $renk");
            ?>">   
        <?php
        echo($not." >> ".$not2);
    ?>
</div>
</body>
</html>
 
Üst