Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a dynamic height on content for each step?

Tags:

jquery-steps

I'm using Jquery steps wizard plugin. The problem I am having is that each step of the wizard has content of a different height. The css included with the examples to control the height for the content is

.wizard > .content
{
    background: #eee;
    display: block;
    margin: 0.5em;
    min-height: 35em;
    overflow: hidden;
    position: relative;
    width: auto;

    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
}

I have tweaked the min-height and overflow properties, but it still doesn't do what I want to accomplish. What I want is the height to be only high enough to accommodate the content for each step.

For example, say I have 2 fields for step 1 and 10 fields for step 2. In the examples the content is all the same height so it looks terrible having a much larger height than is necessary for the 2 fields to accommodate the 10 fields on step 2.

If I remove the min-height property, no content shows at all. Does Jquery steps require a fixed height to work for all steps? I'm hoping there is a way to make the height dynamic to accommodate the height of each individual step.

Thank you

like image 785
sfuptown Avatar asked Apr 02 '14 17:04

sfuptown


People also ask

How do you create dynamic height?

We use css property height: calc( 100% - div_height ); Here, Calc is a function. It uses mathematical expression by this property we can set the height content div area dynamically.

How do I fix dynamic height in CSS?

If you want to fix the height of the div, you can do that by using the “height” property where, once you set the desired height, it will change no matter what is the height of your content.

How dynamically change the height of a div?

The content height of a div can dynamically set or change using height(), innerHeight(), and outerHeight() methods depending upon the user requirement.

How do I set dynamic height in jQuery?

Answer: Use the JavaScript height() method You can set the height of a <div> box dynamically using the jQuery height() method.

How to dynamically set the content height of a Div?

The content height of a div can dynamically set or change using height(), innerHeight(), and outerHeight() methods depending upon the user requirement.

How to change the height of the content of an element?

Using height() method Using innerHeight() method Using outerHeight() method Example 1: Content Height of div using height() methodwill change the height of the content of an element excluding the padding, border, and margin of the element.

What is the height property in CSS and how to use it?

And, for that, CSS provides you with the height property. It is not a single property, it is actually a group of properties, as we have both “min-height” and “max-height.” Do remember that, while setting the height, we only set the height of content — that doesn’t include the padding, border, or margin.

What is the use of auto height in HTML?

height: auto; It is used to set height property to its default value. If the height property set to auto then the browser calculates the height of element. height: length; It is used to set the height of element in form of px, cm etc.


Video Answer


3 Answers

Remove the height property for the below class in jquery.steps.css:

.wizard > .content > .body{height:95%;}

In the - jquery.steps.js search for:

stepTitles.eq(state.currentIndex)
  .addClass("current").next(".body").addClass("current");

Should be around line 844. Directly after, add:

stepTitles.eq(state.currentIndex).next(".body")
    .each(function () {
    var bodyHeight = $(this).height();
    var padding = $(this).innerHeight() - bodyHeight;
    bodyHeight += padding;
    $(this).after('<div class="' + options.clearFixCssClass + '"></div>');
    $(this).parent().animate({ height: bodyHeight }, "slow");
});

The issue will be surely resolved.

like image 138
krb Avatar answered Oct 17 '22 21:10

krb


Just a single line css works for me. It will automatically adjust your height for every section

.wizard > .content > .body{ position: relative !important;}

like image 24
Arman Hakim Sagar Avatar answered Oct 17 '22 22:10

Arman Hakim Sagar


If someone finds this after all those years, the problem is still here. Here is how to fix it without updating javascript, using only css:

.wizard .content {
    min-height: 100px;
}
.wizard .content > .body {
    width: 100%;
    height: auto;
    padding: 15px;
    position: absolute;
}
.wizard .content .body.current {
    position: relative;
}

src: https://github.com/rstaib/jquery-steps/issues/8#issuecomment-368114763

like image 12
Oussama Avatar answered Oct 17 '22 22:10

Oussama