我必须使用 p5.js,并且不能在这个特定项目中使用 CSS。由于 createButton 产生 p5.element,我确实使用了 .style,但我无法使任何超过“宽度”的属性起作用。以下是我想要集成的等效 CSS 属性。您能帮我至少使用以下两种样式作为示例吗?
width: 100 % ; /* Full-width */
height: 25 px; /* Specified height */
background: #d3d3d3; /* Grey background */
outline: none; /* Remove outline */
opacity: 0.7; /* Set transparency (for mouse-over effects on hover) */ -
webkit - transition: .2 s; /* 0.2 seconds transition on hover */
transition: opacity .2 s;
最佳答案
按钮 ( createButton()
) 或 slider ( createSlider()
) 的样式可以通过 .style(name, value)
更改。例如:
button = createButton("my button");
button.style("height", "25 px");
button.style("background", "#d3d3d3");
// [...]
关于javascript - 如何仅使用 javascript 设置通过 p5.js 中的 createButton 函数创建的 slider 的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60062079/