JsDart
JsDart

Reputation: 183

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

Upvotes: 0

Views: 91

Answers (2)

JideLambo
JideLambo

Reputation: 91

Please try this:

div {
   height: calc(100% - 20px)
}

Upvotes: 0

stealththeninja
stealththeninja

Reputation: 3791

Probably could with calc():

height: calc(100% - 20px);

Upvotes: 4

Related Questions