cocoon-child-master テーマをお使いかと思いますが、cocoon-child-master/tmp-user/main-before.php
を編集して以下の記述を追加してみてください。
html
1<style>
2.floating-button {
3 position: fixed;
4 bottom: 10px;
5 right: 10px;
6 display: flex;
7 justify-content: center;
8 align-items: center;
9 width: 80px;
10 height: 80px;
11 border-radius: 100%;
12 background: #0f88c4;
13 color: #fff;
14 text-decoration: none;
15}
16</style>
17<a class="floating-button" href="/path/to/">ボタン</a>
また、基本的にはサイト全体で表示するようにしたいのですが、特定のページのみ表示されないようにしたいです
- 特定のページのみ、
id
または class
属性値を与えておいて、CSS で非表示にする方法
- main-before.php 中で PHP による条件分岐を用いて、特定のページのみコードを出力しない方法
上記の2つの方針が考えられます。特定のページというのは具体的にどのようなページなのでしょうか。それによって具体的なソースコードの記述内容が変わります。
追記
html
1<style>
2#floating-action-button {
3 z-index: 1;
4 position: fixed;
5 bottom: 10px;
6 right: 10px;
7 display: flex;
8 flex-direction: column;
9 justify-content: center;
10 align-items: center;
11 width: 80px;
12 height: 80px;
13 border-radius: 100%;
14 background: #0f88c4;
15 color: #fff;
16 text-decoration: none;
17 font-size: 15px;
18}
19#floating-action-button i {
20 font-size: 20px;
21}
22</style>
23<a id="floating-action-button" href="/path/to/"><i class="fas fa-edit"></i>質問する</a>
24<script>
25(function() {
26 const path = location.pathname;
27 if (path === '/new-thread/' || path.startsWith('/bright/forum/')) {
28 document.getElementById('floating-action-button').remove();
29 }
30}());
31</script>
- a 要素の class 属性を id 属性に変えました
- JavaScript で URL 判定をして
floating-action-button
の削除処理を加えました
- CSS に z-index を追加しました
- HTML に font-awesome アイコンを追加しました
- CSS に flex-direction: column; を追加しました
- CSS に font-size を追加しました