Skip to content

Best way to set the style on a child class? Ex. Setting the width of a button. #250

Answered by wang0618
MostHated asked this question in Q&A
Discussion options

You must be logged in to vote

Here is an example to add custom style to subelement.

css = """
#pywebio-scope-buttons button{
    width:50%;
}
"""
@config(css_style=css)
def main_th():
    with use_scope('buttons'):
        put_row([
            put_buttons(['Start'], onclick=lambda _: action('start')),
            put_buttons(['Stop'], onclick=lambda _: action('stop')),
        ])

The scope in PyWebIO is actually a html div element with pywebio-scope-<scope name> name.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by MostHated
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants