| CSS Selectors(web) |
| <!DOCTYPE html> <html> <head> <style> body { background-color: lightblue; } h1 { color: white; text-align: center; } p { font-family: verdana; font-size: 20px; } </style> </head> <body> <h1>My First CSS Example</h1> <p>This is a paragraph.</p> </body> </html>
|
| <!DOCTYPE html> <html> <head> <style> #para1 { text-align: center; color: red; } </style> </head> <body> <p id="para1">Hello World!</p> <p>This paragraph is not affected by the style.</p> </body> </html>
|
| <!DOCTYPE html> <html> <head> <style> .center { text-align: center; color: red; } </style> </head> <body> <h1 class="center">Red and center-aligned heading</h1> <p class="center">Red and center-aligned paragraph.</p> </body> </html>
|
| <!DOCTYPE html> <html> <head> <style> p.center { text-align: center; color: red; } </style> </head> <body> <h1 class="center">This heading will not be affected</h1> <p class="center">This paragraph will be red and center-aligned.</p> </body> </html>
|
| <!DOCTYPE html> <html> <head> <style> p.center { text-align: center; color: red; } p.large { font-size: 300%; } </style> </head> <body> <h1 class="center">This heading will not be affected</h1> <p class="center">This paragraph will be red and center-aligned.</p> <p class="center large">This paragraph will be red, center-aligned, and in a large font-size.</p> </body> </html>
|
<!DOCTYPE html> <html> <head> <title>Javascript example</title> </head> <body> <h2>My First JavaScript</h2> <button type="button" onclick="document.getElementById('demo').innerHTML = Date()"> Click me to display Date and Time. </button> <p id="demo"></p> </body> </html>
|
| <!DOCTYPE html> <html> <head> <title>CSS & javascript Example</title> <style> body { background-color: lightblue; } p { color: red; font-size: 20px; } </style> </head> <body> <h2>My First JavaScript</h2> <button type="button" onclick="document.getElementById('demo').innerHTML = Date()"> Click me to display Date and Time.</button> <p id="demo"></p> </body> </html>
|
| <!DOCTYPE html> <html> <head> <style> .center { text-align: center; } </style> </head> <body> <h2>Center Text</h2> <div class="center"> <h1>This text is centered.</h1> <button>Button</button> </div> </body> </html> |
| W3School(web)(javascript) |
| #include <ESP8266WebServer.h> #define ssid "myEsp"//自訂 SSID CSggx #define pw "12345678" //自訂密碼至少8個字 #define port 80 String s = R"=====( <!DOCTYPE html> <html> <head> <title>CSS & javascript Example</title> <style> body { background-color: lightblue; } p { color: red; font-size: 20px; } </style> </head> <body> <h2>My First JavaScript</h2> <button type="button" onclick="document.getElementById('demo').innerHTML = Date()"> Click me to display Date and Time.</button> <p id="demo"></p> </body> </html> )====="; ESP8266WebServer server(port); void handleRoot() { server.send(200, "text/html", s); } void setup(void){ WiFi.softAP(ssid, pw); server.on("/", handleRoot); server.begin(); } void loop(void){ server.handleClient(); }
|
| #include <ESP8266WebServer.h> #define ssid "asusTony"//寬頻分享器 SSID #define pw "123456789A" //寬頻分享器密碼 #define port 80 String s = R"=====( <!DOCTYPE html> <html> <head> <meta name='viewport' content='width=device-width, initial-scale=1.0'/> <meta charset='utf-8'> <title>CSS & javascript Example</title> <style> body { background-color: lightblue; } p { color: red; font-size: 20px; } </style> </head> <body> <h2>My First JavaScript</h2> <button type="button" onclick="document.getElementById('demo').innerHTML = Date()"> Click me to display Date and Time.</button> <p id="demo"></p> </body> </html> )====="; ESP8266WebServer server(port); void handleRoot() { server.send(200, "text/html", s); } void setup(void){ WiFi.begin(ssid, pw); while (!(WiFi.status() == WL_CONNECTED)) { delay(1000); } WiFi.mode(WIFI_AP_STA); WiFi.softAP(String("IP-"+ String((WiFi.localIP().toString()))),""); server.begin(); server.on("/", handleRoot); } void loop(void){ server.handleClient(); }
|
|
#include <ESP8266WebServer.h> ESP8266WebServer server(80); void handleRoot() { String s = R"=====( <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name='viewport' content='width=device-width, initial-scale=1.0'/> <title>LED Control</title> </head> <body> <h1> <center> <p>LED 控制<br></p> <form> <input type="submit" formaction="/1" value="ON" style="width:300px;height:100px;font-size:48px"> <input type="submit" formaction="/0" value="OFF" style="width:300px;height:100px;font-size:48px"> </form> </center> </h1> </body> </html> )====="; server.send(200, "text/html", s); } void ledON() { digitalWrite(2, LOW); server.sendHeader("Location","/"); server.send(303); } void ledOFF() { digitalWrite(2, HIGH); server.sendHeader("Location","/"); server.send(303); } void setup() { pinMode(2, OUTPUT); digitalWrite(2, HIGH); WiFi.begin("asusTony", "123456789A"); while (!(WiFi.status() == WL_CONNECTED)) { delay(1000); } WiFi.mode(WIFI_AP_STA); WiFi.softAP(String("IP-"+ String((WiFi.localIP().toString()))),""); digitalWrite(2,LOW); server.begin(); server.on("/", handleRoot); server.on("/1", ledON); server.on("/0", ledOFF); } void loop() { server.handleClient(); }
|