如何使博客第一段话的第一个字漂亮的大写?


你看!本文的第一段话的第一个字大写!

很容易的, 只需要用到CSS的 first-letterfirst-child 选择器:

只要将下面的CSS先添加到WORDPRESS的模板里(比如可以放在 Single.php)

1
2
3
4
5
6
7
8
9
10
11
12
<style>
.wp_content p:first-child:first-letter { 
  float: left; 
  color: #903; 
  font-size: 75px; 
  line-height: 60px; 
  padding-top: 4px; 
  padding-right: 8px; 
  padding-left: 3px; 
  font-family: Georgia; 
}
</style>
<style>
.wp_content p:first-child:first-letter { 
  float: left; 
  color: #903; 
  font-size: 75px; 
  line-height: 60px; 
  padding-top: 4px; 
  padding-right: 8px; 
  padding-left: 3px; 
  font-family: Georgia; 
}
</style>

然后在模板函数 functions.php 的最后添加以下几行代码:

1
2
3
4
5
6
// https://helloacm.com
add_filter( 'the_content', 'prefix_big_letter' );
 
function prefix_big_letter($content) {
  return "<div class='wp_content'>$content</div>";
}
// https://helloacm.com
add_filter( 'the_content', 'prefix_big_letter' );

function prefix_big_letter($content) {
  return "<div class='wp_content'>$content</div>";
}

就可以了, 清一下缓存, 然后可以看效果.代码也不需要我过多的解释, 简单粗暴有效! 转走吧,不用谢!

查看英文效果, 请看: https://helloacm.com/how-to-make-first-letter-in-first-paragraph-big-in-wordpress-css-articles/

GD Star Rating
loading...
本文一共 116 个汉字, 你数一下对不对.
如何使博客第一段话的第一个字漂亮的大写?. (AMP 移动加速版本)
上一篇: 公司请的专业摄影师
下一篇: 翻出一支钢笔

扫描二维码,分享本文到微信朋友圈
0e00ea34bc7e7b2663351533cb0a4887 如何使博客第一段话的第一个字漂亮的大写? 互联网 折腾 有意思的 网站信息与统计

11 条评论

  1. 兔二爷 | 理性的感性生活
    • 兔二爷 | 理性的感性生活
    • 兔二爷 | 理性的感性生活
  2. 里念

评论