开发者

CSS - can't get style properties

I have a div called "box" but i can't use css style from file style.css

<div id="right">


        <?php
            $cc = 1;
        for($i=1; $i<=71; $i++)
            {
                $query = mysql_query("SELECT * FROM photos WHERE product_id='".$i."'");
                $row = mysql_fetch_array($query);
                $t="img/";
                $file = $t .$row[1];
                if($cc % 5 == 1) echo "<ul>";
                echo '<li><div id="box"><a href="#"><img src =thumb.php?file=' . $file . '&size=120></a></div></li开发者_JS百科>';
                if($cc % 5 ==0) echo "</ul>";
                $cc ++;
                } ?>


    </div> 

If i put the css style declaration inline it's working

 #right {
/*margin-left: 12em;*/
padding-left: 50px;
border-left: 1px solid #CCC;
 }
 #right img {
border: 1px solid #CCC;
 }
#right li { display: inline-block; }


#box {width: 150px; height: 150px; background-color: white; text-align: center;padding-top:20px;}

What is the problem?


Post your style.css (to make sure it is correct), and full page html source (to make sure you include style.css correctly).

CSS should look like:

#box {
width: 150px; 
height: 150px; 
background-color: white;
text-align: center;
padding-top:20px;
}


Rewrite of the first statement:

echo '<li><div id="box"><a href="#"><img src="thumb.php?file=' . $file . '&size=120"></a></div></li>';

Minor rewrite of the second statement:

echo '<li><div style="width: 150px; height: 150px; background-color: white; text-align: center; padding-top:20px;">';

Try them out and let me know if it works a bit better (some parts of your HTML was a bit malformed, so I adjusted them).

Also, it wouldn't hurt if you enclosed the relevant <link rel="stylesheet" href="link_to_stylesheet.css" />and also the actual css for div#box.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜