I recently designed a basic webpage using HTML with two main elements - a chat window for user interaction and a chart.js plot. Here is a snippet of the HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible">
<link rel="shortcut icon" href="#" />
<link rel="stylesheet" href="{{ url_for('static', filename='styles/style.css') }}">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
...
</head>
<body>
<section class="msger">
<header class="msger-header">
<div class="msger-header-title">
<!-- Buttons here -->
</div>
</header>
<main class="msger-chat">
<div class="container" id="start-btn">
<button class="start-btn" type="button" onClick="start()">
Start Conversation
</button>
</div>
<div class="msg left-msg">
</div>
</main>
<form class="msger-inputarea" id="msger-input">
<input type="text" class="msger-input" id="textInput" placeholder="Enter your message..." style="display:none">
<button type="submit" class="msger-send-btn" style="display:none" id="sendInput">Send</button>
</form>
</section>
<div style="height: 50vh; width: 50%;">
<canvas id="myChart"></canvas>
</div>
</body>
</html>
Below is a snippet of the accompanying CSS styling:
:root {
/* Variables */
}
/* Styles go here */
Currently, I'm encountering three challenges with this setup:
The placement of the chart.js plot alongside the chat window appears fine on larger screens but becomes problematic on smaller devices like mobile phones. Is it feasible to adjust the positioning so that on larger screens, the plot is on the right of the chat window, and on smaller screens, it appears below?
The chart.js plot seems excessively wide in relation to the chat window. Is there a way to modify the widths so that the chat window occupies 60% of the screen width while the plot takes up 40%, adjusting its height accordingly?
When zooming out the webpage, the chat window shrinks while the chart.js plot expands. Is there a solution to maintain consistent widths for both elements when zooming in or out?