From ce89247a9cda67ba2b1dbefeaf7b0ed692be2365 Mon Sep 17 00:00:00 2001 From: wangjiacai Date: Tue, 4 Apr 2023 00:38:02 +0800 Subject: [PATCH] message auto wrap --- project/templates/chat.html | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/project/templates/chat.html b/project/templates/chat.html index 48c041e..28418c7 100644 --- a/project/templates/chat.html +++ b/project/templates/chat.html @@ -54,14 +54,12 @@ if (msg.response == "" && msg.request != "") { li.style.textAlign = "right" pre.innerText = msg.request - pre.style.backgroundColor = "lightblue" + pre.style = "background-color: lightblue; border-radius: 10px; padding: 5px; white-space: pre-wrap; word-wrap: break-word;" } else if (msg.request != "") { li.style.textAlign = "left" pre.innerText = msg.response - pre.style.backgroundColor = "lightgreen" + pre.style = "background-color: lightgreen; border-radius: 10px; padding: 5px; white-space: pre-wrap; word-wrap: break-word;" } - pre.style.borderRadius = "10px" - pre.style.padding = "5px" msg_list.appendChild(li) }) window.scrollTo(0,document.documentElement.scrollHeight) @@ -85,9 +83,7 @@ li.style.textAlign="right" li.style.marginBottom="20px" pre.innerText=data.msg - pre.style.backgroundColor="lightblue" - pre.style.borderRadius="10px" - pre.style.padding="5px" + pre.style = "background-color: lightblue; border-radius: 10px; padding: 5px; white-space: pre-wrap; word-wrap: break-word;" msg_list.appendChild(li) } msgbox.value="" @@ -108,9 +104,7 @@ pre.innerText=response.message li.style.textAlign="left" li.style.marginBottom="20px" - pre.style.backgroundColor="lightgreen" - pre.style.borderRadius="10px" - pre.style.padding="5px" + pre.style = "background-color: lightgreen; border-radius: 10px; padding: 5px; white-space: pre-wrap; word-wrap: break-word;" msg_list.appendChild(li) msg_list.appendChild(document.createElement('br')) }