Open ralph-bergmann opened 3 years ago
Got the same error, @the4thfloor have you resolved that?
label("border pr-1 pl-1 text-xs text-muted") {
attrs { style = "border-radius: 2em;" }
}
div {
attrs {
style = object { val width = 600.px }.asDynamic()
}
}
or
div {
attrs {
style = js("({width:'600.px'})")
}
}
react style need object,but kotlinx.html style is string, so use dynamic hack it
This works with typings, but I wonder if style
can be used as a parameter of html-tags, just like React.JS.
div {
+"Hello from JS"
}.apply {
this.style.color = "red"
}
Why not just:
div { attributes["style"] = "color: white; background-color: #bada55" +"some content" }
?
div { attrs { style = js("({width:'600.px'})") } }
Should it be 600px
instead of 600.px
?
I'm a newbie and I'm wondering how I can add inline styling to a div element.
Finally I need something like this:
<div id='map' style='width: 400px; height: 300px;'></div>
.Adding the
id
was with the help of Google not so complicated:But I failed with adding the inline style :-(
Near the
id
attribute I found thestyle
attribute (https://github.com/Kotlin/kotlinx.html/blob/master/src/commonMain/kotlin/generated/gen-attr-traits.kt#L337). It expects aString
, so I tried:It fails with this error message:
I tried what the error message says:
Now I get an
Unresolved reference: marginRight
error in the IDE.How can I add some inline styling to a
div
?