httpswift / swifter

Tiny http server engine written in Swift programming language.
BSD 3-Clause "New" or "Revised" License
3.9k stars 539 forks source link

CSS / style in header #510

Open MattTimmons opened 2 years ago

MattTimmons commented 2 years ago

Would someone be able to provide a sample of using css styling with Swifter? I have not had luck getting it to work...

            html {
                head {
                    style {
                        bgcolor = "#b51f6a;"
                        background = "#b51f6a;"
                        color = "#b51f6a;"
                    }
                }

Or better yet, an example of using in css file as part of the app resources.

Thanks!

chockenberry commented 2 years ago

I used this:

style {
    inner = """

body {
    color: pink;
    background-color: red;
}

h1 {
   font-family: "MS Comic Sans";
   font-size: 100px;
}

"""
}

You can also move that into a separate String variable to use it in different page contexts.

-ch