wordpress增加彩色文本框

╭飛雪飄零╮ 2018/08/0923:05:204133,1851 4189字

wordpress的文章摘要是不是很丑,使用纯CSS即可实现彩色文本框效果,美化文章。下面给出具体教程

具体效果如下:

绿色提示框
红色提示框
黄色提示框
灰色提示框
蓝色提示框
黑色提示框
虚线提示框
绿边提示框
红边提示框

步骤一:添加代码

在主题functions.php文件最后添加如下代码:

代码一:

/*彩色文本框 开始*/
function toz($atts, $content=null){
 return '<div id="sc_notice">'.$content.'</div>';
}
add_shortcode('v_notice','toz');
function toa($atts, $content=null){
 return '<div id="sc_error">'.$content.'</div>';
}
add_shortcode('v_error','toa');
function toc($atts, $content=null){
 return '<div id="sc_warn">'.$content.'</div>';
}
add_shortcode('v_warn','toc');
function tob($atts, $content=null){
 return '<div id="sc_tips">'.$content.'</div>';
}
add_shortcode('v_tips','tob');
function tod($atts, $content=null){
 return '<div id="sc_blue">'.$content.'</div>';
}
add_shortcode('v_blue','tod');
function toe($atts, $content=null){
 return '<div id="sc_black">'.$content.'</div>';
}
add_shortcode('v_black','toe');
function tof($atts, $content=null){
 return '<div id="sc_xuk">'.$content.'</div>';
}
add_shortcode('v_xuk','tof');
function tog($atts, $content=null){
 return '<div id="sc_lvb">'.$content.'</div>';
}
add_shortcode('v_lvb','tog');
function toh($atts, $content=null){
 return '<div id="sc_redb">'.$content.'</div>';
}
add_shortcode('v_redb','toh');
function toi($atts, $content=null){
 return '<div id="sc_orange">'.$content.'</div>';
}
add_shortcode('v_orange','toi');
/*彩色文本框 结束*/

代码二:

/*添加文本编辑自定义快捷标签按钮 开始*/
 add_action('after_wp_tiny_mce', 'bolo_after_wp_tiny_mce');
 function bolo_after_wp_tiny_mce($mce_settings) {
 ?>
 <script type="text/javascript">
 QTags.addButton( 'v_notice', '绿框', '<div id="sc_notice">绿色提示框</div>\n', "" );
 QTags.addButton( 'v_error', '红框', '<div id="sc_error">红色提示框</div>\n', "" );
 QTags.addButton( 'v_warn', '黄框', '<div id="sc_warn">黄色提示框</div>\n', "" );
 QTags.addButton( 'v_tips', '灰框', '<div id="sc_tips">灰色提示框</div>\n', "" );
 QTags.addButton( 'v_blue', '蓝框', '<div id="sc_blue">蓝色提示框</div>\n', "" );
 QTags.addButton( 'v_black', '黑框', '<div id="sc_black">黑色提示框</div>\n', "" );
 QTags.addButton( 'v_xuk', '虚线', '<div id="sc_xuk">虚线提示框</div>\n', "" );
 QTags.addButton( 'v_lvb', '绿边', '<div id="sc_lvb">绿边提示框</div>\n', "" );
 QTags.addButton( 'v_redb', '红边', '<div id="sc_redb">红边提示框</div>\n', "" );
 function bolo_QTnextpage_arg1() {
 }
 </script>
 <?php
 }
 /*添加文本编辑自定义快捷标签按钮 结束*/

步骤二:添加CSS

在主题文件style.css中添加如下代码:

请把https://www.luoyechenfei.com/wp-content/themes/love替换为自己的图片地址。
/*cai se wen ben kuang*/
#sc_notice {
 color: #7da33c;
 background: #ecf2d6 url('https://www.luoyechenfei.com/wp-content/themes/love/img/sc_notice.png') -1px -1px no-repeat;
 border: 1px solid #aac66d;
 overflow: hidden;
 margin: 10px 0;
 padding: 15px 15px 15px 35px;
 }
#sc_warn {
 color: #ad9948;
 background: #fff4b9 url('https://www.luoyechenfei.com/wp-content/themes/love/img/sc_warn.png') -1px -1px no-repeat;
 border: 1px solid #eac946;
 overflow: hidden;
 margin: 10px 0;
 padding: 15px 15px 15px 35px;
 }
#sc_error {
 color: #c66;
 background: #ffecea url('https://www.luoyechenfei.com/wp-content/themes/love/img/sc_error.png') -1px -1px no-repeat;
 border: 1px solid #ebb1b1;
 overflow: hidden;
 margin: 10px 0;
 padding: 15px 15px 15px 35px;
 }
#sc_tips {
 color: #777;
 background: #eaeaea url('https://www.luoyechenfei.com/wp-content/themes/love/img/sc_tips.png') -1px -1px no-repeat;
 border: 1px solid #ccc;
 overflow: hidden;
 margin: 10px 0;
 padding: 15px 15px 15px 35px;
}
#sc_blue {
 color: #1ba1e2;
 background: rgba(27, 161, 226, 0.26) url('https://www.luoyechenfei.com/wp-content/themes/love/img/sc_blue.png') -1px -1px no-repeat;
 border: 1px solid #1ba1e2;
 overflow: hidden;
 margin: 10px 0;
 padding: 15px 15px 15px 35px;
}
#sc_black {
 border-width: 1px 4px 4px 1px;
 border-style: solid;
 border-color: #3e3e3e;
 margin: 10px 0;
 padding: 15px 15px 15px 35px;
}
#sc_xuk {
 border: 2px dashed rgb(41, 170, 227);
 background-color: rgb(248, 247, 245);
 margin: 10px 0;
 padding: 15px 15px 15px 35px;
}
#sc_lvb {
 margin: 10px 0;
 padding: 10px 15px;
 border: 1px solid #e3e3e3;
 border-left: 2px solid #05B536;
 background: #FFF;
}
#sc_redb {
 margin: 10px 0;
 padding: 10px 15px;
 border: 1px solid #e3e3e3;
 border-left: 2px solid #ED0505;
 background: #FFF;
}
#sc_organge {
 margin: 10px 0;
 padding: 10px 15px;
 border: 1px solid #e3e3e3;
 border-left: 2px solid #EC8006;
 background: #FFF;
}

步骤三:上传图片文件

上传附件的图片到主题下的img文件中。

下载信息 资源名称:彩色文本框图片 应用平台:WinXP/Vista/Win7/Win8/Win10 资源版本:1.0 资源大小:2.4k
网盘密码:发表评论并刷新可见
下载地址
继续阅读
站长最后更新:2020-2-4
╭飛雪飄零╮
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

评论:41   其中:访客  26   博主  15
    • 墨铺 墨铺 0
      Google Chrome 103.0.0.0 Google Chrome 103.0.0.0 Windows 7 x64 Edition Windows 7 x64 Edition

      太需要了,泪流满面

      • CLAM CLAM 0
        Google Chrome 86.0.4240.198 Google Chrome 86.0.4240.198 Windows 7 x64 Edition Windows 7 x64 Edition

        好的非常感谢

        • zaqwsx zaqwsx 1
          Google Chrome 86.0.4240.198 Google Chrome 86.0.4240.198 Windows 10 x64 Edition Windows 10 x64 Edition

          挺好看的

          • 111 111 0
            Google Chrome 86.0.4240.198 Google Chrome 86.0.4240.198 Windows 10 x64 Edition Windows 10 x64 Edition

            感谢分享

            • 溪风 溪风 0
              UC Browser 6.2.4098.3 UC Browser 6.2.4098.3 Windows 10 x64 Edition Windows 10 x64 Edition

              非常完美

              • 123456 123456 0
                Google Chrome 78.0.3904.108 Google Chrome 78.0.3904.108 Windows 7 x64 Edition Windows 7 x64 Edition

                感谢分享!!!

                • 3 3 0
                  Google Chrome 79.0.3945.117 Google Chrome 79.0.3945.117 Windows 10 x64 Edition Windows 10 x64 Edition

                  感谢分享!!!

                  • a504111 a504111 0
                    Google Chrome 78.0.3904.108 Google Chrome 78.0.3904.108 Windows 7 x64 Edition Windows 7 x64 Edition

                    感谢分享!!!

                    • 松鼠小 松鼠小 0
                      Google Chrome 79.0.3945.130 Google Chrome 79.0.3945.130 Windows 8.1 x64 Edition Windows 8.1 x64 Edition

                      挺好看的!

                      • exile exile 1
                        Firefox 72.0 Firefox 72.0 Windows 10 x64 Edition Windows 10 x64 Edition

                        评论了为啥还是看不到啊

                        • exile exile 1
                          Firefox 72.0 Firefox 72.0 Windows 10 x64 Edition Windows 10 x64 Edition

                          good-好

                          • 猪肉佬 猪肉佬 0
                            Google Chrome 63.0.3239.132 Google Chrome 63.0.3239.132 Windows 7 x64 Edition Windows 7 x64 Edition

                            good支持

                            • itdog itdog 0
                              Google Chrome 69.0.3497.100 Google Chrome 69.0.3497.100 Windows 7 x64 Edition Windows 7 x64 Edition

                              感谢分享,不错哦

                              • 前臂 前臂 0
                                Google Chrome 63.0.3239.132 Google Chrome 63.0.3239.132 Windows 10 x64 Edition Windows 10 x64 Edition

                                看卡怎么样

                                • 艾特好 艾特好 0
                                  Opera 4.0 Opera 4.0 Android 8.0.0 Android 8.0.0

                                  看看怎么样

                                  • 小鱼 小鱼 0
                                    QQbrowser 10.3.2601.400 QQbrowser 10.3.2601.400 Windows 10 x64 Edition Windows 10 x64 Edition

                                    看看密码

                                    • soujer soujer 0
                                      Google Chrome 63.0.3239.132 Google Chrome 63.0.3239.132 Windows 10 x64 Edition Windows 10 x64 Edition

                                      看看密码好不好

                                      • 仙教圣教主 仙教圣教主 0
                                        Google Chrome 70.0.3538.110 Google Chrome 70.0.3538.110 Windows 10 x64 Edition Windows 10 x64 Edition

                                        看看密码

                                        • 李想 李想 0
                                          UC Browser 6.2.4094.1 UC Browser 6.2.4094.1 Windows 7 x64 Edition Windows 7 x64 Edition

                                          很棒,谢谢楼主

                                          • 屌丝小小鸭 屌丝小小鸭 1
                                            Google Chrome 63.0.3239.132 Google Chrome 63.0.3239.132 Windows 10 x64 Edition Windows 10 x64 Edition

                                            代码二添加在什么地方,我添加到functions.php,报错了

                                            • 浅醉 浅醉 1
                                              Google Chrome 63.0.3239.132 Google Chrome 63.0.3239.132 Windows 7 x64 Edition Windows 7 x64 Edition

                                              支持

                                              • 似乎 似乎 0
                                                Google Chrome 67.0.3396.99 Google Chrome 67.0.3396.99 Windows 10 x64 Edition Windows 10 x64 Edition

                                                感谢分享

                                                • xgky xgky 0
                                                  QQbrowser 10.2.1893.400 QQbrowser 10.2.1893.400 Windows 7 x64 Edition Windows 7 x64 Edition

                                                  漂亮,这个不错