31 lines
No EOL
844 B
C++
31 lines
No EOL
844 B
C++
import Crafter.CppDOM;
|
|
using namespace Crafter;
|
|
|
|
int main(){
|
|
HtmlElementPtr body("body","<div id=\"myDiv\"></div>");
|
|
// Create a div element
|
|
HtmlElementPtr div("myDiv");
|
|
|
|
// Set some initial content
|
|
div.SetInnerHTML("<p>This is a styled paragraph</p>");
|
|
|
|
// Apply styles using different methods
|
|
div.SetStyle("color: blue; font-size: 20px; background-color: lightgray;");
|
|
|
|
// Or apply individual properties
|
|
div.SetProperty("border", "2px solid red");
|
|
div.SetProperty("padding", "10px");
|
|
|
|
// Add CSS classes
|
|
div.AddClass("highlight");
|
|
div.AddClass("container");
|
|
|
|
// Demonstrate class toggling
|
|
div.ToggleClass("active");
|
|
|
|
// Check if class exists
|
|
bool hasActiveClass = div.HasClass("active");
|
|
|
|
// Remove a class
|
|
div.RemoveClass("highlight");
|
|
} |