【问题标题】:How do you style the admin/backend of the ACF (Advanced Custom Fields) Wordpress plugin?您如何设计 ACF(高级自定义字段)Wordpress 插件的管理/后端?
【发布时间】:2018-03-25 22:48:55
【问题描述】:

当您有很多选项时,ACF 后端/管理面板可能会变得非常混乱。我看到您可以在哪里更改宽度百分比并将您自己的类添加到自定义字段,但是您如何设置这些类的样式?只是将这些类名添加到 style.css 是行不通的!

【问题讨论】:

    标签: css wordpress-theming advanced-custom-fields


    【解决方案1】:

    您必须将此代码添加到您的functions.php 文件中。 这里有一些docs

    function my_acf_admin_head() {
        ?>
        <style type="text/css">
    
        /* css here */
    
        </style>
        <?php
    }
    
    add_action('acf/input/admin_head', 'my_acf_admin_head');
    

    这是我使用的代码。它使 ACF Admin 看起来更好:

    function my_acf_admin_head() {
    ?>
    <style type="text/css">
    
        .acf-flexible-content .layout .acf-fc-layout-handle {
            /*background-color: #00B8E4;*/
            background-color: #202428;
            color: #eee;
        }
    
        .acf-repeater.-row > table > tbody > tr > td,
        .acf-repeater.-block > table > tbody > tr > td {
            border-top: 2px solid #202428;
        }
    
        .acf-repeater .acf-row-handle {
            vertical-align: top !important;
            padding-top: 16px;
        }
    
        .acf-repeater .acf-row-handle span {
            font-size: 20px;
            font-weight: bold;
            color: #202428;
        }
    
        .imageUpload img {
            width: 75px;
        }
    
        .acf-repeater .acf-row-handle .acf-icon.-minus {
            top: 30px;
        }
    
    </style>
    <?php
    }
    
    add_action('acf/input/admin_head', 'my_acf_admin_head');
    

    【讨论】:

    • 选项页面怎么样?
    【解决方案2】:

    作为 Jesse 完美回答的补充,想分享我对 ACF Metabox 的 CSS 补充,日历也有样式。

    这就是它的样子

    享受

    function my_acf_admin_head() {
        ?>
        <style type="text/css">
    
            .acf-flexible-content .layout .acf-fc-layout-handle {
                /*background-color: #00B8E4;*/
                background-color: #202428;
                color: #eee;
            }
    
            .acf-repeater.-row > table > tbody > tr > td,
            .acf-repeater.-block > table > tbody > tr > td {
                border-top: 2px solid #202428;
            }
    
            .acf-repeater .acf-row-handle {
                vertical-align: top !important;
                padding-top: 16px;
            }
    
            .acf-repeater .acf-row-handle span {
                font-size: 20px;
                font-weight: bold;
                color: #202428;
            }
    
            .imageUpload img {
                width: 75px;
            }
    
            .acf-repeater .acf-row-handle .acf-icon.-minus {
                top: 30px;
            }
            .acf_postbox {
                background-color: #0473AA;
                border-radius: 5px;
            }
            .acf_postbox input[type=text],
            .acf_postbox input[type=search],
            .acf_postbox input[type=radio],
            .acf_postbox input[type=tel],
            .acf_postbox input[type=time],
            .acf_postbox input[type=url],
            .acf_postbox input[type=week],
            .acf_postbox input[type=password],
            .acf_postbox input[type=checkbox],
            .acf_postbox input[type=color],
            .acf_postbox input[type=date],
            .acf_postbox input[type=datetime],
            .acf_postbox input[type=datetime-local],
            .acf_postbox input[type=email],
            .acf_postbox input[type=month],
            .acf_postbox input[type=number],
            .acf_postbox select,
            .acf_postbox textarea {
                border-radius: 5px;
            }
    
            .acf_postbox p.label {
                text-shadow: none;
            }
    
            .acf_postbox h2.hndle,
            .acf_postbox p.label label,
            .acf_postbox p.label,
            .acf_postbox .toggle-indicator {
                color: #ffffff;
            }
    
            /*---- Date Picker Style ----*/
    
            .ui-acf .ui-datepicker select.ui-datepicker-month,
            .ui-acf .ui-datepicker select.ui-datepicker-year {
                border-radius: 5px;
            }
    
            .ui-acf .ui-state-default{
                border: 1px solid #ffffff!important;
                background: none!important;
            }
    
            .ui-acf .ui-datepicker .ui-state-active, .ui-acf .ui-state-default:hover {
                background: #2EA2CC!important;
                color: #ffffff;
            }
    
            .ui-acf .ui-widget-header {
               background: #3e3e3e;
            }
    
            .ui-acf .ui-datepicker .ui-datepicker-buttonpane {
                background: #0473AA;
                border-top: none;
            }
    
            .ui-acf .ui-datepicker .ui-datepicker-buttonpane button {
                text-shadow: none;
                color: #ffffff;
                text-decoration: underline;
                border: none!important;
            }
        </style>
        <?php
        }
    
        add_action('acf/input/admin_head', 'my_acf_admin_head');
    

    【讨论】:

    • 选项页面怎么样?
    【解决方案3】:

    如果你想发疯(或停止发疯),你可以做这样的事情并根据需要添加尽可能多的 'n'。

    .acf-repeater.-row > table > tbody > tr:nth-child(2n) > td,
    .acf-repeater.-block > table > tbody > tr:nth-child(2n) > td,
    .acf-repeater.-row > table > tbody > tr:nth-child(2n) > td tr > td,
    .acf-repeater.-block > table > tbody > tr:nth-child(2n) > td tr > td {
        border-top: 2px solid #46474A;
        background: #ebebed;
    }
    
    .acf-repeater.-row > table > tbody > tr:nth-child(2n) .acf-row-handle span,
    .acf-repeater.-block > table > tbody > tr:nth-child(2n) .acf-row-handle span,
    .acf-repeater.-row > table > tbody > tr:nth-child(2n) > td .acf-row-handle span,
    .acf-repeater.-block > table > tbody > tr:nth-child(2n) > td .acf-row-handle span{
        color: #46474A;
    }   
    

    【讨论】:

    • 选项页面怎么样?
    猜你喜欢
    • 2018-07-11
    • 1970-01-01
    • 2018-08-15
    • 2019-04-11
    • 2020-12-18
    • 2012-11-26
    • 1970-01-01
    • 1970-01-01
    • 2018-10-12
    相关资源
    最近更新 更多