2

I have a div on my page that contains breadcrumb with php code, but when I style it with css it doesn't.

I mean if I put styling code in css file & link that file to my file.php it doesn't work unless I put styling code on file.php.

any solution for this ?

Code in file.php

<div class="s_crumb">
<?php
    $Pages = array(
      'Clothes' => 'Clothes',
      'file' => 'File'
    );

    $path = $_SERVER["PHP_SELF"];
    $parts = explode('/',$path);
    if (count($parts) < 2)
    {
    echo("home");
    }
    else
    {
    echo ("<a href=\"http://domain.com\">Home</a> &raquo; ");
    for ($i = 2; $i < count($parts); $i++)
        {
        if (!strstr($parts[$i],"."))
            {
            echo("<a href=\"");
            for ($j = 0; $j <= $i; $j++) {echo $parts[$j]."/";};
            echo("\">". str_replace('-', ' ', $Pages[$parts[$i]])."</a> &raquo; ");
            }
        else
            {
            $str = $parts[$i];
            $pos = strrpos($str,".");
            $parts[$i] = substr($str, 0, $pos);
            echo str_replace('-', ' ', $Pages[$parts[$i]]);
            };
        };
    };  
?>
</div>

CSS code

<style>
.s_crumb a {color:#848484;text-decoration:none;}
.s_crumb a:visited {color:#848484;text-decoration:none;}
.s_crumb a:hover {color:#bebebe;text-decoration:none;}
</style>
11
  • Are you loading your css file in properly in your php file? Commented Feb 14, 2017 at 11:16
  • how you are adding css file into this file? tell us. Are you doing something like this:- <link href="css/my.css" rel="stylesheet" type="text/css"> Commented Feb 14, 2017 at 11:16
  • all other divs with styling works the way i linked my css file but only this one doesn't work here is how i linked my css file <link href="css/css.css" rel="stylesheet" type="text/css"> @Anant Commented Feb 14, 2017 at 11:20
  • working fine at my end with your style code Commented Feb 14, 2017 at 11:22
  • @Samir what i think, maybe it's because the page loads php code first then that div can't get styling from css file ? Commented Feb 14, 2017 at 11:23

1 Answer 1

1

Two things:-

Add style like below:-

<link href="css/css.css" rel="stylesheet" type="text/css">

Multiple time due to cache css file are not working. So try to remove your cache and then check

Also css.css need to be like below:-

.s_crumb a {color:#848484;text-decoration:none;}
.s_crumb a:visited {color:#848484;text-decoration:none;}
.s_crumb a:hover {color:#bebebe;text-decoration:none;}

remove <style> and </style> from there

Note:- i tired your code and working fine at my end.

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.