Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.18.0
|
8 |
-
app_file:
|
9 |
pinned: false
|
|
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
+
|
2 |
---
|
3 |
+
title: custom_css_main
|
4 |
+
emoji: 🔥
|
5 |
+
colorFrom: indigo
|
6 |
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 4.18.0
|
9 |
+
app_file: run.py
|
10 |
pinned: false
|
11 |
+
hf_oauth: true
|
12 |
---
|
|
|
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
https://gradio-builds.s3.amazonaws.com/dff410955e41145848376784c03fe28ba1c4fd85/gradio-4.18.0-py3-none-any.whl
|
run.ipynb
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: custom_css"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "css = \"\"\"\n", "/* CSSKeyframesRule for animation */\n", "@keyframes animation {\n", " from {background-color: red;}\n", " to {background-color: blue;}\n", "}\n", "\n", ".cool-col {\n", " animation-name: animation;\n", " animation-duration: 4s;\n", " animation-iteration-count: infinite;\n", " border-radius: 10px;\n", " padding: 20px;\n", "}\n", "\n", "/* CSSStyleRule */\n", ".markdown {\n", " background-color: lightblue;\n", " padding: 20px;\n", "}\n", "\n", ".markdown p {\n", " color: royalblue;\n", "}\n", "\n", "/* CSSMediaRule */\n", "@media screen and (max-width: 600px) {\n", " .markdown {\n", " background: blue;\n", " }\n", " .markdown p {\n", " color: lightblue;\n", " }\n", "}\n", "\n", ".dark .markdown {\n", " background: pink;\n", "}\n", "\n", ".darktest h3 {\n", " color: black;\n", "}\n", "\n", ".dark .darktest h3 {\n", " color: yellow;\n", "}\n", "\n", "/* CSSFontFaceRule */\n", "@font-face {\n", " font-family: \"test-font\";\n", " src: url(\"https://mdn.github.io/css-examples/web-fonts/VeraSeBd.ttf\") format(\"truetype\");\n", "}\n", "\n", ".cool-col {\n", " font-family: \"test-font\";\n", "}\n", "\n", "/* CSSImportRule */\n", "@import url(\"https://fonts.googleapis.com/css2?family=Protest+Riot&display=swap\");\n", "\n", ".markdown {\n", " font-family: \"Protest Riot\", sans-serif;\n", "}\n", "\"\"\"\n", "\n", "with gr.Blocks(css=css) as demo:\n", " with gr.Column(elem_classes=\"cool-col\"):\n", " gr.Markdown(\"### Gradio Demo with Custom CSS\", elem_classes=\"darktest\")\n", " gr.Markdown(elem_classes=\"markdown\", value=\"Resize the browser window to see the CSS media query in action.\")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
css = """
|
4 |
+
/* CSSKeyframesRule for animation */
|
5 |
+
@keyframes animation {
|
6 |
+
from {background-color: red;}
|
7 |
+
to {background-color: blue;}
|
8 |
+
}
|
9 |
+
|
10 |
+
.cool-col {
|
11 |
+
animation-name: animation;
|
12 |
+
animation-duration: 4s;
|
13 |
+
animation-iteration-count: infinite;
|
14 |
+
border-radius: 10px;
|
15 |
+
padding: 20px;
|
16 |
+
}
|
17 |
+
|
18 |
+
/* CSSStyleRule */
|
19 |
+
.markdown {
|
20 |
+
background-color: lightblue;
|
21 |
+
padding: 20px;
|
22 |
+
}
|
23 |
+
|
24 |
+
.markdown p {
|
25 |
+
color: royalblue;
|
26 |
+
}
|
27 |
+
|
28 |
+
/* CSSMediaRule */
|
29 |
+
@media screen and (max-width: 600px) {
|
30 |
+
.markdown {
|
31 |
+
background: blue;
|
32 |
+
}
|
33 |
+
.markdown p {
|
34 |
+
color: lightblue;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
.dark .markdown {
|
39 |
+
background: pink;
|
40 |
+
}
|
41 |
+
|
42 |
+
.darktest h3 {
|
43 |
+
color: black;
|
44 |
+
}
|
45 |
+
|
46 |
+
.dark .darktest h3 {
|
47 |
+
color: yellow;
|
48 |
+
}
|
49 |
+
|
50 |
+
/* CSSFontFaceRule */
|
51 |
+
@font-face {
|
52 |
+
font-family: "test-font";
|
53 |
+
src: url("https://mdn.github.io/css-examples/web-fonts/VeraSeBd.ttf") format("truetype");
|
54 |
+
}
|
55 |
+
|
56 |
+
.cool-col {
|
57 |
+
font-family: "test-font";
|
58 |
+
}
|
59 |
+
|
60 |
+
/* CSSImportRule */
|
61 |
+
@import url("https://fonts.googleapis.com/css2?family=Protest+Riot&display=swap");
|
62 |
+
|
63 |
+
.markdown {
|
64 |
+
font-family: "Protest Riot", sans-serif;
|
65 |
+
}
|
66 |
+
"""
|
67 |
+
|
68 |
+
with gr.Blocks(css=css) as demo:
|
69 |
+
with gr.Column(elem_classes="cool-col"):
|
70 |
+
gr.Markdown("### Gradio Demo with Custom CSS", elem_classes="darktest")
|
71 |
+
gr.Markdown(elem_classes="markdown", value="Resize the browser window to see the CSS media query in action.")
|
72 |
+
|
73 |
+
if __name__ == "__main__":
|
74 |
+
demo.launch()
|