Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using auto in CSS calc

Tags:

css

I searched a lot but I didn't find a good resource.

I want to calculate a div height as its contents plus a fix size. I tested calc(auto+50px) but unfortunately It doesn't work (the browser does not interpret it as valid code).

like image 468
CoderInNetwork Avatar asked Aug 21 '13 19:08

CoderInNetwork


People also ask

What is Auto used for in CSS?

The auto Value You can set the margin property to auto to horizontally center the element within its container. The element will then take up the specified width, and the remaining space will be split equally between the left and right margins.

Can I use Calc in CSS?

calc() The calc() CSS function lets you perform calculations when specifying CSS property values. It can be used anywhere a <length> , <frequency> , <angle> , <time> , <percentage> , <number> , or <integer> is allowed.

Can I use Calc for margin CSS?

You can use calc() anywhere where you would use numeric values (e.g.: width, max-height, margin-left, …) Can I Use calc? Data on support for the calc feature across the major browsers from caniuse.com.

How do you calculate height in CSS?

In this case we use jquery to calculate the height of content div area. But now using CSS we can set height without making header and footer height fixed or using jquery function. We use css property height: calc( 100% - div_height ); Here, Calc is a function.


1 Answers

Does this produce the desired result?

div {
    height: auto;
    padding-bottom: 50px;
}
like image 135
rink.attendant.6 Avatar answered Sep 24 '22 16:09

rink.attendant.6