0

I am developing a website wherein I have two icons in the header and these two icons have badges on them. And I've implemented these badges using pseudocodes(after/before). Now the problem I'm facing is, I've to run a counter and for that I have to use php in the css file. Basically I need to calculate the "content" (100 is a dummy value).

I am adding the code below to help you understand the issue.

could it be done? How could it be done? and what would be the extension of the file?

TIA

.badgeq:after {
        content: "100";
        position: relative;
        background: rgba(0,0,255,1);
        height: 2rem;
        top: 0rem;
        right: 0.5rem;
        width: 2rem;
        text-align: -webkit-center;
        line-height: 2rem;
        font-size: 1rem;
        border-radius: 50%;
        color: white;
        border: 1px solid blue;
    }

    .badgeq {
        display: flex;
        min-width: 10px;
        padding: 3px 7px;
        font-size: 12px;
        font-weight: 700;
        line-height: 1;
        color: #35BBE6;
        text-align: center;
        white-space: nowrap;
        vertical-align: middle;
        background-color: transparent;
        border-radius: 10px;
    }
    a.badgeq:focus, a.badgeq:hover {
        color: #27408b;
        text-decoration: none;
        cursor: pointer;
    }
    
    <?php

    include('dbConnect.php');

     
        if(!isset($_SESSION['zuser_id5'] ) || empty($_SESSION['zuser_id5']))
        {
            if(!isset($_SESSION['zuser_id9'] ) || empty($_SESSION['zuser_id9']))
            {header("Location: /"); }
        }


        ?>
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8"/>
        <meta name="author" content="Vaibhav Chouhan Abhishek Kashyap Srishti Mahatma"/>
        <meta name="description" content="Zigzobs|Revolutionizing Recruitment">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0 user-scalable=no">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <link rel="stylesheet" href="css/style.css">
        <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
        <link rel="shortcut icon" href="images/zigsaw.png">
        <title>Zigzobs|Revolutionizing Recruitment</title>
    </head>
    <body>
    <nav class="navbar navbar-default navbar-justified">
            <div class="container">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed " data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand logo" href="user.php"><img src="images/zigsaw.png" class="img-responsive" alt="logo"></a>
                </div>
                
                    
                <div class="nav navbar-nav navbar-center navbar-header">
                    <ul class="list-inline">
                        <li><a href="notificationpage.php"  class="badge badgeq"><i class="fa fa-bell fa-2x" aria-hidden="true"></i></a></li>
                        <li><a href="msg1.php" class="badge badgeq"><i class="fa fa-comment fa-2x " aria-hidden="true"></i></a></li>
                    </ul>
                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse navbar-right" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <li><a href="user.php">Home<span class="sr-only">(current)</span></a></li>
                        <li><a href="alljobs.php">Selling</a></li>
                        <li><a href="employerhome.php">Buying</a></li>
                        <!-- <li><a href="applicationstatus.html">Status</a></li> -->
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Add Credits</a>
                            <ul class="dropdown-menu">
                                <li><a href="https://rzp.io/i/RXDp" target="_blank"><i class="fa fa-inr" aria-hidden="true"></i>500</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="https://rzp.io/i/fTRj" target="_blank"><i class="fa fa-inr" aria-hidden="true"></i>1000</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="https://rzp.io/i/Q4Ex" target="_blank"><i class="fa fa-inr" aria-hidden="true"></i>2000</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="https://rzp.io/i/3TKh" target="_blank"><i class="fa fa-inr" aria-hidden="true"></i>5000</a></li>
                                <li role="separator" class="divider"></li>
                                <li><a href="https://rzp.io/i/kQmh" target="_blank"><i class="fa fa-inr" aria-hidden="true"></i>10000</a></li>
                            </ul>
                        </li>
                    </ul>
                    <form class="navbar-form navbar-left" method="post" action="searchjob.php">
                        <div class="form-group">
                            <input type="text" class="form-control" placeholder="Search Jobs" name="keyword_job">
                        </div>
                        <button type="submit" class="btn btn-default" name="submito">Search</button>
                    </form>

                </div><!-- /.navbar-collapse -->
            </div><!-- /.container-fluid -->
        </nav>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script src="https://use.fontawesome.com/6a575d0f1f.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
        <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
    </body>
    </html>

1 Answer 1

0

PHP in a CSS file can be done, awkwardly - but why not just to throw a <span> into .badgeq and write the number there in the template, instead of using :after?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.