我正在尝试将我的框的背景内容颜色从白色更改为#222d32(或任何自定义颜色),但是在使用background
参数时,我收到错误Error in validateColor(background) :
Invalid color: #222d32. Valid colors are: red, yellow, aqua, blue, light-blue, green, navy, teal, olive, lime, orange, fuchsia, purple, maroon, black.
以下代码:
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(width = 6, title = "test", status = "primary", solidHeader = TRUE, background = '#222d32',
"Box content"
)
)
)
)
server <- function(input, output) {}
shinyApp(ui, server)
我还尝试创建一个自定义包装器来捕获<div>
并修改它,但是没有成功。代码如下:
library(shiny)
library(shinydashboard)
box_customBackground <- function(box_object, color = NULL){
new_color_class <- paste0('<div class="box box-solid ', color ,'">')
box_modify <- gsub('<div class="box">', new_color_class, box_object)
box_html <- HTML(box_modify)
return(box_html)
}
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
box_customBackground(box_object = box(
actionButton(inputId = 'SelectGroup', label = 'Change Groups'),
checkboxGroupInput(inputId = 'SimulationType', choices = c('Growth', 'Step'), selected = 'Growth',
label = NULL, inline = TRUE),
width = 5), color = '#222d32'
)
)
)
)
server <- function(input, output) {}
shinyApp(ui, server)
答案 0 :(得分:3)
如果您只想更改框内容的背景,请执行以下操作:
onClick($event): void {
let clientHeight = $event.target.clientHeight; //Height + padding without borders
let offsetHeight = $event.target.offsetHeight; //Height + padding with borders
//if you need the element plus margin-top/bottom
let compStyle = window.getComputedStyle($event.target)
clientHeight += parseInt(compStyle.getPropertyValue('margin-top'));
clientHeight += parseInt(compStyle.getPropertyValue('margin-bottom'));
}
如果你想改变方框中的所有内容,请执行以下操作:
String str2 = buyInNumEditText.getText().toString();
float num1 = Float.parseFloat(str1);
float num2 = Float.parseFloat(str2);
float num3 = 3;
float num4 = 100;
float num5 = num1 + num3;
float num6 = num5 / num4;
float num7 = num6 * num2;
float num8 = num7 + num2;
DecimalFormat formatter = new DecimalFormat("##.########");
String num9 = formatter.format(num8);