dongshi2458 2014-10-17 15:54
浏览 16

在PHP中使用css类

I have to set up this function, which gets a value out of a custom field in a Wordpress article editor. It works and displays the price I inserted in the editor (e.g. 20,00)

BUT I can't style it using css.

<div class="price">
   <p>
      <?php echo '<div class="price">'. get_post_meta( get_the_ID(), 'price', true).'</div>'; ?>€
   </p>
</div>

This is my css file:

.price { font-size:50px; color:#8e8e8e;  }

Why does the css not apply to the code?

  • 写回答

1条回答 默认 最新

  • duandai0373 2014-10-17 16:01
    关注

    CSS applied with PHP is no different than any other CSS. That's not the problem.

    It's probably a matter of some other CSS with a more specific selector overriding your definition for .price. Also, make sure that the path to your CSS file is correct and the code is loading. To diagnose this, load the script in your browser and use the code inspector to look at the div with the .price class. It will show you all the CSS applied to the element and you will be able to see if your .price class rules are being applied and if they are overridden by another rule.

    Get to know your code inspector - FireBug for FireFox is a valuable add-on, and Chrome has decent inspector built in. It's a powerful tool to figure out styling problems, among other things.

    评论

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)