Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
154 views
in Technique[技术] by (71.8m points)

javascript - Calculate the height value of DIV as a function of SCSS and use it as the height of another DIV

Error image and direction of purpose

The DIV height value must be calculated as a function of SCSS and used at a different DIV height.

I searched but couldn't find the SCSS function that calculates the height of another div using an internal variable.

I'm trying to create a chat window, and I hope that the input box for this chat is position: absolute and always at the bottom.

The problem is that the text you type increases the height of the chat entry box. This means that the exact height is not determined in the chat.

A problem was found that determines the height of the dark red chat content.

The chat history field could not be set to calc() because it is not a fixed height, resulting in an error similar to the one in the middle.

The last picture is what I want.

Can the SCSS function receive the height of the chat input box to determine the height of the chat content?

I would like to solve this problem with SCSS or CSS as much as possible, but if not, I can use pure JavaScript. (Not jQuery.)

<div class="parent1">
    <div class="chat-history">
       <p>abdcdaceasdfasdfddasfdefdafdadfsdfdasdfdsfasdfasdf</p>
    </div>
    <div class="chat-input"></div>
</div>
.parent1 {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
}

.chat-history {
    width: 100%
} // I'd like to calculate the height of this.

.chat-input {
    display: flex;
    position: absolute;
    bottom: 0;
    min-width: 70px;
    max-height: 140px;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Please try this:

.parent1{display:flex;width:100%;height:50vh;position:relative;}


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...