如何使用ContactForm7在Wordpress中添加FontAwesome图标以提交按钮?

mat*_*mat 2 wordpress contact-form-7

我正在尝试使用ContactForm7在Wordpress中添加fontawesome箭头图标以提交按钮。我有这个:[提交类:按钮“发送消息”]在CSS:

.wpcf7-submit:before {
    content: '\f30b';
    font-family: 'Font Awesome 5 Free' !important;
}
Run Code Online (Sandbox Code Playgroud)

而且它不起作用,有什么想法吗?

coo*_*ops 7

我知道我参加聚会有点晚了,但是我刚刚找到了一个更简单的选择(或者至少我是这么认为的),可以帮助我在“提交”按钮上获得一个图标。

不需要伪元素,您只需将元素直接插入联系表单即可:

<!--add the following instead of [submit] in Contact Form 7-->
<button type="submit" class="wpcf7-submit">Send Message<i class="fas fa-arrow-circle-right"></i></button>
<img class="ajax-loader" src="/wp-content/plugins/contact-form-7/images/ajax-loader.gif" alt="Sending ..." style="visibility: hidden; opacity: 1;">
Run Code Online (Sandbox Code Playgroud)

然后,您还可以像这样向按钮添加样式:

/*Then you can add whatever style you want to your button*/

button.wpcf7-submit {
  background: #31D1D3;
  padding: 10px 15px;
  border: 0;
}

button.wpcf7-submit i {
  margin-left: 5px
}

button.wpcf7-submit:hover {
  color: white;
}

button.wpcf7-submit:hover i {
  color: white;
}
Run Code Online (Sandbox Code Playgroud)
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
<!--just for this example, presume you already have font awesome installed if you're looking to output a button-->


<!--add the following instead of [submit] in Contact Form 7-->

<button type="submit" class="btn primary wpcf7-submit">Send Message<i class="fas fa-arrow-circle-right"></i></button>
<img class="ajax-loader" src="/wp-content/plugins/contact-form-7/images/ajax-loader.gif" alt="Sending ..." style="visibility: hidden; opacity: 1;">
Run Code Online (Sandbox Code Playgroud)

更新:

您甚至可以使用Font Awesome Ajax Loader来代替CF7!

/*Then you can add whatever style you want to your button*/

button.wpcf7-submit {
  background: #31D1D3;
  padding: 10px 15px;
  border: 0;
}

button.wpcf7-submit i {
  margin-left: 5px
}

button.wpcf7-submit:hover {
  color: white;
}

button.wpcf7-submit:hover i {
  color: white;
}
Run Code Online (Sandbox Code Playgroud)
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
<!--just for this example, presume you already have font awesome installed if you're looking to output a button-->


<!--add the following instead of [submit] in Contact Form 7-->

<button type="submit" class="btn primary wpcf7-submit">Send Message<i class="fas fa-arrow-circle-right"></i></button>
<i class="fab fa-github ajax-loader" style="visibility: hidden; opacity: 1;"></i>
Run Code Online (Sandbox Code Playgroud)