WordPress 美化后台登陆界面

Gavin Wu 2022年04月12日 8:04 Wordpress 1,476 Views

一、在主题的functions.php文件中添加上以下代码

1
2
3
4
5
/** * WordPress 登录界面美化 **/
function custom_login_style() {
    echo '<link rel="stylesheet" id="wp-admin-css" href="'.get_bloginfo('template_directory').'/admin-style.css" type="text/css" />';
    }
add_action('login_head', 'custom_login_style');

二、在主题根目录新建admin-style.css文件

admin-style.css文件要与function.php在同一目录,一般在主题根目录,
[collapse title=’admin-style代码’]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
    美化wordpress后台登陆界面
        微言心语
    https://wuean.com/wordpress-beautify-background-login.html
*/

body{
    font-family: "Microsoft YaHei", Helvetica, Arial, Lucida Grande, Tahoma, sans-serif;
    width:100%;
    height:100%;
    background: url(https://wuean.com/wp-content/uploads/2021/01/39fe2a8e575c6de3cef4e88b1cb9fed0.jpeg) no-repeat; /*建议使用1920*1080以上图片*/
    -moz-background-size: cover; /*背景图片拉伸以铺满全屏*/
    -ms-background-size: cover;
    -webkit-background-size: cover;
    background-size: cover;
    }
    /*顶部的logo*/
    .login h1 a {
    background:url(https://wuean.com/wp-content/themes/justlove1.1/images/uugai.com_1646226550119.png) no-repeat;
    background-size: 220px 67px;
    width: 220px;
    height: 67px;
    padding: 0;
    margin: 0 auto 1em;
    border: none;
    -webkit-animation: dropIn 1s linear;
    animation: dropIn 1s linear;
    }
    /*登录框表单*/
    .login form, .login .message {
    background: #fff;
   background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    border: 1px solid #fff;
   border: 1px solid rgba(255, 255, 255, 0.4);
    -webkit-animation: fadeIn 1s linear;
    animation: fadeIn 1s linear;
    }
    /*登录框输入框*/
    .login label {
    color: #000;
   }
    .login .message {
    color: #000;
   }
    #user_login{
   font-size: 18px;
    line-height: 32px;
    }
    /* 返回博客与忘记密码链接 */
    #backtoblog a, #nav a {
   color: #fff !important;
   display: inline-block;
    -webkit-animation: rtol 1s linear;
    animation: rtol 1s linear;
    }
    /*掉落的动画效果*/
    @-webkit-keyframes dropIn {
    0% {
    -webkit-transform: translate3d(0, -100px, 0)
    }
    100% {
    -webkit-transform: translate3d(0, 0, 0)
    }
    }
    @keyframes dropIn {
    0% {
    transform: translate3d(0, -100px, 0)
    }
    100% {
    transform: translate3d(0, 0, 0)
    }
    }
    /*逐渐出现的动画效果*/
    @-webkit-keyframes fadeIn {
    from {
    opacity: 0;
    -webkit-transform: scale(.8) translateY(20px)
    }
    to {
    opacity: 1;
    -webkit-transform: scale(1) translateY(0)
    }
    }
    @keyframes fadeIn {
    from {
    opacity: 0;
    transform: scale(.8) translateY(20px)
    }
    to {
    opacity: 1;
    transform: scale(1) translateY(0)
    }
    }
    /*从右往左的动画效果*/
    @-webkit-keyframes rtol {
    from {
    -webkit-transform: translate(80px, 0)
    }
    to {
    -webkit-transform: translate(0, 0)
    }
    }
    @keyframes rtol {
    from {
    transform: translate(80px, 0)
    }
    to {
    transform: translate(0, 0)
    }
    }

[/collapse]

当然,你也可以下载我做好的文件

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Top