Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

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

javascript - Reducing the height of a div by a set amount?

I have a div that can dynamically grow; but due to some of the elements being higher than what they are by having a position: relative; the div is a little taller than what it needs to be.

The elements can have multiple lines; so the height of the div is not-constant, but regardless of how many lines these elements are, there's always a little "overhang"/ blank space.

Is there any way I can reduce the height of a div by a fixed amount. I'm thinking along the lines of

100% of the div's height - 20px

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

Probably could with calc():

height: calc(100% - 20px);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...