首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >断线Javascript InnerText

断线Javascript InnerText
EN

Stack Overflow用户
提问于 2020-10-17 22:52:07
回答 2查看 40关注 0票数 1

所以,我制作了一个简单的便笺应用程序,它以卡片的形式显示笔记,带有标题和所有这些。现在我有麻烦了。当人们在没有按enter键的情况下,在写句子时输入enter移动到下一行时,notecard也会以文本区域的方式显示它。但是,我希望它在行之间插入断点,这样它就不会在notecard中溢出。

这里有一幅画:它应该像下面的音符,但它就像第一个音符。https://gyazo.com/4d3d75908b7eccb64522be67f621530e

我需要添加哪些代码,如CSS或javascript?

,我已经为卡片段落放了90%的最大宽度,但是它似乎忽略了它,只会溢出。

代码语言:javascript
复制
// Main Variables

let noteForm = document.querySelector("form");
let headlineInput = document.getElementById("headline-input");
let noteInput = document.getElementById("note-input");
let submitButton = document.getElementById("submit-button");
let noteSection = document.getElementById("notes");
let container = document.getElementById("container");
let currentNotes = document.getElementById("current-notes");

// Create Elements on Click

function addElement() {

    if (headlineInput.value.length == 0 || (noteInput.value.length == 0)){
        console.log("Input value null");
        return;
    }
    //Create all elements

    let noteCard = document.createElement("div");
    noteSection.appendChild(noteCard);
    noteCard.className = "notecard";

    let noteHead = document.createElement("h2");
    noteCard.appendChild(noteHead);
    noteHead.className = "note-headline";

    let noteParagraph = document.createElement("p");
    noteCard.append(noteParagraph);
    noteParagraph.className = "note-paragraph";
代码语言:javascript
复制
.notecard {
    border:1px solid rgb(243, 242, 242);
    border-radius:5px;
    box-shadow:0px 0px 10px rgba(0, 0, 0, 0.075);
    margin-bottom:50px;
    padding:20px;
}
.notecard h2 {
    margin-bottom:20px;
    border-bottom:2px solid #16e0bd;
    display:inline-block;
    padding-bottom: 10px;
}
.notecard p {
    margin-bottom:30px;
    color:rgb(59, 59, 59);
    font-size:15px;
    max-width:900px;
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-10-17 23:22:17

我把便笺-段落设计成这样(我在px中设置了宽度,但应该与上面的容器相同。)

代码语言:javascript
复制
.note-paragraph{
  width: 500px;
    white-space: pre-wrap;
    overflow: auto;
    word-break: break-all;
  
}

你可以在这里看到它,https://jsfiddle.net/e9zdxomy/1/

票数 1
EN

Stack Overflow用户

发布于 2020-10-17 23:43:53

max-width:900px;移动到.notecard

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64408115

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档