# カスタマイズボタンの位置調整について

**URL:** https://community.cybozu.dev/t/topic/6653
**Category:** kintone 開発相談
**Created:** [2020 年 8 月 25 日午後 12:42 UTC](https://community.cybozu.dev/t/topic/6653 "2020-08-25T12:42:35Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Legacy\_Account2342](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Legacy\_Account2342](https://community.cybozu.dev/u/Legacy_Account2342)
#### Post date: [2020 年 8 月 25 日午後 12:42 UTC](https://community.cybozu.dev/t/topic/6653/1 "2020-08-25T12:42:35Z")

</div>

お世話になります。

はじめようKintone APIを参考にしながらボタンを作成しております。

[https://developer.cybozu.io/hc/ja/articles/201767270-第2回-レコード一覧画面にボタンを置いてみよう-](https://community.cybozu.dev/hc/ja/articles/201767270-%E7%AC%AC2%E5%9B%9E-%E3%83%AC%E3%82%B3%E3%83%BC%E3%83%89%E4%B8%80%E8%A6%A7%E7%94%BB%E9%9D%A2%E3%81%AB%E3%83%9C%E3%82%BF%E3%83%B3%E3%82%92%E7%BD%AE%E3%81%84%E3%81%A6%E3%81%BF%E3%82%88%E3%81%86-)

&nbsp;

kintone.app.getHeaderSpaceElement()を活用してボタンの配置をしたいのですが、ボタンの位置が左寄せになってしまいます。

右寄せにするにはどの様にしたら宜しいのでしょうか？

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー

(function() {  
“use strict”;  
kintone.events.on(‘app.record.index.show’, function(event) {  
if (document.getElementById(‘my\_index\_button’) !== null) {  
return;  
}

var myIndexButton = document.createElement(‘button’);  
myIndexButton.id = ‘my\_index\_button’;  
myIndexButton.innerText = ‘一覧のボタン’;  
kintone.app.getHeaderSpaceElement().appendChild(myIndexButton);  
});  
})();

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー

&nbsp;

また、ヘッダーのスペースだけではなく、フッターのスペースにボタンを配置することは可能なのでしょうか？

&nbsp;

どうぞ宜しくお願いします。

---

<div class="post-metadata">

### Author: ![Legacy\_Account2229](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Legacy\_Account2229](https://community.cybozu.dev/u/Legacy_Account2229)
#### Post date: [2020 年 8 月 29 日午前 5:54 UTC](https://community.cybozu.dev/t/topic/6653/2 "2020-08-29T05:54:03Z")

</div>

y.hasebeさん

こんにちは。

右寄せは、cssを使って可能です。

また、kintoneの標準APIでは、フッターを取得するイベントが無いのですが、DOM操作で可能ではあります。

＜JavaScript＞

```
(function() {

 "use strict";

 kintone.events.on('app.record.index.show', function(event) {

  if (document.getElementById('my_index_button') !== null) {
   return;
  }

  var myIndexButton = document.createElement('button');
  myIndexButton.id = 'my_index_button';
  myIndexButton.innerText = '一覧のボタン';
  kintone.app.getHeaderSpaceElement().appendChild(myIndexButton);

  if (document.getElementById('my_footer_button') !== null) {
   return;
  }

  var myFooterButton = document.createElement('button');
  myFooterButton.id = 'my_footer_button';
  myFooterButton.innerText = 'フッターのボタン';
  document.getElementsByClassName('contents-bottommenu-gaia')[0].appendChild(myFooterButton);

 });

})();

```

＜CSS＞

```
/* ヘッダースペース内を右寄せ */
.kintone-app-header-space {
 text-align: right;
}

/* フッタースペース内を右寄せ */
.contents-bottommenu-gaia {
 text-align: right;
}

```

&nbsp;

---

<div class="post-metadata">

### Author: ![Legacy\_Account2342](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Legacy\_Account2342](https://community.cybozu.dev/u/Legacy_Account2342)
#### Post date: [2020 年 8 月 31 日午後 12:44 UTC](https://community.cybozu.dev/t/topic/6653/3 "2020-08-31T12:44:29Z")

</div>

koichi 様

お世話になっております。

ご教示いただき大変ありがとうございます。

フッターの中にもボタンを配置することができ、思っていたことができるようになりました。

&nbsp;

また、いただいたCSSをアップしてみたのですがヘッダー部フッター部とも配置が変わりませんでした。

他のCSSを削除したり様々試してみたのですが何か方法はございますでしょうか。

&nbsp;

どうぞ宜しくお願いいたします。

&nbsp;

---

<div class="post-metadata">

### Author: ![Legacy\_Account2229](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Legacy\_Account2229](https://community.cybozu.dev/u/Legacy_Account2229)
#### Post date: [2020 年 9 月 1 日午前 7:03 UTC](https://community.cybozu.dev/t/topic/6653/4 "2020-09-01T07:03:23Z")

</div>

y.hasebe様

ご確認ありがとうございます。

上記のcssを適用すると、配置は下記画像のようになるはずなのですが、、

差し支えなければ、現在適用中のcssの中身を投稿いただけないでしょうか。

---

<div class="post-metadata">

### Author: ![Legacy\_Account2342](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Legacy\_Account2342](https://community.cybozu.dev/u/Legacy_Account2342)
#### Post date: [2020 年 9 月 2 日午前 4:57 UTC](https://community.cybozu.dev/t/topic/6653/5 "2020-09-02T04:57:53Z")

</div>

koichi 様

ご連絡いただきありがとうございます。

適用しているソースですが、koichi様からいただいたものを変更せずに使用している状態です。

[javascript]

* * *

(function()&nbsp;{

&nbsp;&nbsp;&nbsp;&nbsp; “use&nbsp;strict”;&nbsp; &nbsp;

&nbsp;&nbsp;&nbsp;&nbsp; kintone.events.on(‘app.record.index.show’,&nbsp;function(event)&nbsp;{&nbsp; &nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp; if&nbsp;(document.getElementById(‘my\_index\_button’)&nbsp;!==&nbsp;null)&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp; return;  
&nbsp;&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp;&nbsp; var&nbsp;myIndexButton&nbsp;=&nbsp;document.createElement(‘button’);  
&nbsp;&nbsp;&nbsp;&nbsp; myIndexButton.id&nbsp;=&nbsp;‘my\_index\_button’;  
&nbsp;&nbsp;&nbsp;&nbsp; myIndexButton.innerText&nbsp;=&nbsp;‘一覧のボタン’;  
&nbsp;&nbsp;&nbsp;&nbsp; kintone.app.getHeaderSpaceElement().appendChild(myIndexButton);

&nbsp;&nbsp;&nbsp;&nbsp; if&nbsp;(document.getElementById(‘my\_footer\_button’)&nbsp;!==&nbsp;null)&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp; return;  
&nbsp;&nbsp;&nbsp;&nbsp; }  
&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp; var&nbsp;myFooterButton&nbsp;=&nbsp;document.createElement(‘button’);  
&nbsp;&nbsp;&nbsp;&nbsp; myFooterButton.id&nbsp;=&nbsp;‘my\_footer\_button’;  
&nbsp;&nbsp;&nbsp;&nbsp; myFooterButton.innerText&nbsp;=&nbsp;‘フッターのボタン’;  
&nbsp;&nbsp;&nbsp;&nbsp; document.getElementsByClassName(‘contents-bottommenu-gaia’)[0].appendChild(myFooterButton);  
&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp; });  
&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;})();

* * *

[css]

* * *

/\* ヘッダースペース内を右寄せ \*/  
.kintone-app-header-space {  
text-align: right;  
}

/\* フッタースペース内を右寄せ \*/  
.contents-bottommenu-gaia {  
text-align: right;  
}

* * *

このjavascriptとcssをアップすると、ボタンは出るのですが右には寄らない状態になっております。

私のCSSの内容やアップのやり方が悪いのだとは思いますが…

宜しくお願いいたします。

---

<div class="post-metadata">

### Author: ![Legacy\_Account2229](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@Legacy\_Account2229](https://community.cybozu.dev/u/Legacy_Account2229)
#### Post date: [2020 年 9 月 2 日午前 8:08 UTC](https://community.cybozu.dev/t/topic/6653/6 "2020-09-02T08:08:31Z")

</div>

y.hasebe様

添付ありがとうございます。

cssですが、「text-align: right;」の前に全角スペースが入っていないでしょうか。

半角スペースまたはTabに修正すれば解決しそうです。

---

<div class="post-metadata">

### Author: ![Legacy\_Account2342](https://avatars.discourse-cdn.com/v4/letter/l/ed8c4c/32.png) [@Legacy\_Account2342](https://community.cybozu.dev/u/Legacy_Account2342)
#### Post date: [2020 年 9 月 2 日午前 8:44 UTC](https://community.cybozu.dev/t/topic/6653/7 "2020-09-02T08:44:41Z")

</div>

koichi 様

お世話になっております。

ご指摘の通り全角スペースとなっておりました。

無事にボタンを右に寄せることができました。

あれこれ試していたのですが気がつきませんでした…

&nbsp;

様々ご教示いただき大変ありがとうございました。

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/cybozu/original/1X/d5c841c3c5a6cb66eed514001c1b45147c9e1f4f.png) [@system](https://community.cybozu.dev/u/system)
#### Post date: [2024 年 9 月 6 日午前 8:39 UTC](https://community.cybozu.dev/t/topic/6653/8 "2024-09-06T08:39:44Z")

</div>

このトピックはベストアンサーに選ばれた返信から 3 日が経過したので自動的にクローズされました。新たに返信することはできません。
