【发布时间】:2019-10-18 06:35:53
【问题描述】:
我正在创建一个按钮以转到页面底部,并且我希望按钮背景颜色与触摸视口的第一个元素相同。 按钮正在工作,但我无法获得顶部元素颜色。 检查此图像以了解我需要什么。 https://i.ibb.co/4SrqGQW/Screenshot-20191018-114922.jpg
我当前的代码
// ==UserScript==
// @name bottom button
// @namespace bottom
// @description go to bottom
// @include *://*/*
// @grant GM_addStyle
// @noframes
// ==/UserScript==
var btmbtn = document.createElement("div");
btmbtn.innerHTML = '<div id="bottom1">▼</div>';
btmbtn.onclick = function() {
window.scrollTo(0,document.body.scrollHeight);
};
document.getElementsByTagName("html").item(0).appendChild(btmbtn);
GM_addStyle ( `
#bottom1 {
background-color: blue;
position: fixed;
bottom: 10vw;
right: 2vw;
z-index: 9999999;
border-radius: 100%;
width: 10vw;
height: 10vw;
font-size: 5vw;
text-align: center;
line-height: 10vw;
}
` );
【问题讨论】:
-
请向我们展示您的代码。
-
添加了我当前的代码。 @Carsten Løvbo Andersen
标签: javascript jquery google-chrome userscripts