-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtmltester.html
123 lines (118 loc) · 3.96 KB
/
htmltester.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html>
<head>
<title>Welcome!</title>
<link rel="icon" type="image/x-icon" href="favicon.svg">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lexend:[email protected]&display=swap" rel="stylesheet">
<link rel="stylesheet" href="style.css">
<style>
body {
display: flex;
justify-content: space-between;
height: 100vh;
margin: 0;
padding: 20px;
font-family: 'Lexend', sans-serif;
}
.navbar {
background-color: #333;
padding: 10px;
text-align: center;
}
.navbar a {
color: white;
text-decoration: none;
margin: 0 15px;
}
h1, p {
margin: 10px 0;
}
#editor {
flex: 1;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
#preview {
flex: 1;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
overflow: auto; /* Ensures iframe content that overflows is scrollable */
}
#previewFrame {
width: 100%;
height: 100%;
border: none;
}
textarea {
width: 100%;
height: calc(100% - 40px); /* Adjusts textarea height to fit remaining space */
padding: 5px;
font-family: 'Lexend', sans-serif;
font-size: 14px;
border: 1px solid #ccc;
border-radius: 5px;
resize: none; /* Prevents textarea from being resized by user */
white-space: pre-wrap; /* Preserves white space and allows wrapping */
}
button {
margin-top: 10px;
padding: 8px 15px;
font-size: 14px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="navbar">
<a href="https://randomuser12342.github.io">Home</a>
<a href="https://randomuser12342.github.io/projects">Projects</a>
</div>
<div id="editor">
<h2>Enter Your HTML Code:</h2>
<textarea id="htmlInput" rows="20" placeholder="Enter your HTML code here..."></textarea>
<br>
<button onclick="updatePreview()">Update Preview</button>
</div>
<div id="preview">
<h2>Preview:</h2>
<iframe id="previewFrame" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" frameborder="0"></iframe>
</div>
<script>
function updatePreview() {
var htmlCode = document.getElementById('htmlInput').value;
// Create a complete HTML document with specified CSS and HTML content
var iframeContent = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Preview</title>
<style>
/* Include styles specific to the iframe content */
body {
font-family: 'Lexend', sans-serif;
padding: 20px;
}
/* Additional specific styles can be added here */
</style>
</head>
<body>
${htmlCode}
</body>
</html>
`;
// Set the iframe content
var previewFrame = document.getElementById('previewFrame');
previewFrame.srcdoc = iframeContent;
}
</script>
</body>
</html>