Javascript 添加按钮-并排

Javascript 添加按钮-并排,javascript,css,greasemonkey,tampermonkey,Javascript,Css,Greasemonkey,Tampermonkey,我正在使用chrome上的Tampermonkey向网页添加按钮。单击时,脚本分析页面,然后显示警报。这是显示按钮的代码: function Main(){ GM_addStyle('.myButtonDiv {color: black; background-color: black}'); var div = document.createElement('div'); div.setAttribute('class', 'myButtonDiv');

我正在使用chrome上的Tampermonkey向网页添加按钮。单击时,脚本分析页面,然后显示警报。这是显示按钮的代码:

 function Main(){
     GM_addStyle('.myButtonDiv {color: black; background-color: black}');
     var div = document.createElement('div');
     div.setAttribute('class', 'myButtonDiv');
     div.innerHTML = '<input type="button" value="clickMe">';
     document.body.insertBefore(div, document.body.firstChild);
     div.firstChild.addEventListener('click', runMyScript, true);
}
函数Main(){
GM_addStyle('.myButtonDiv{color:black;background color:black}');
var div=document.createElement('div');
div.setAttribute('class','myButtonDiv');
div.innerHTML='';
document.body.insertBefore(div,document.body.firstChild);
div.firstChild.addEventListener('click',runMyScript,true);
}
我有几个脚本可以在同一页上运行。现在按钮是垂直显示的,这占用了太多的屏幕空间

如何将它们并排放置在一排中

谢谢,
Nir.

显示:内联块添加到CSS应该会有所帮助

GM_addStyle('.myButtonDiv {color: black; background-color: black; display: inline-block}');

您可以使用内联元素:

 GM_addStyle('.myButtonSpan {color: black; background-color: black}');
 var span = document.createElement('span');
 span.setAttribute('class', 'myButtonSpan');
 span.innerHTML = '<input type="button" value="clickMe">';
 document.body.insertBefore(span, document.body.firstChild);
 span.firstChild.addEventListener('click', runMyScript, true);
GM_addStyle('.myButtonSpan{color:black;background color:black}');
var span=document.createElement('span');
setAttribute('class','myButtonSpan');
span.innerHTML='';
document.body.insertBefore(span,document.body.firstChild);
span.firstChild.addEventListener('click',runMyScript,true);