Angular Set Dynamic Height for element of his parent div

Liad Livnat

I have the following scenario:

 <div class="parent" style="height:100%">
        <div class="left" style="float:left" dynamic-height element-id="{{$index}}">
        </div>
        <div class="right" style="float:left">
            <div>Element 1</div>
            <div>Element 2</div>
    </div>
    </div>

I'm trying that the left element will be at the same height as the .right or the .parent, i tried to add directive for that, with not much success, anyone have a better idea?

the directive:

.directive('dynamicHeight', function() {
    return {
        compile: function compile(tElement, tAttrs, transclude) {
            return {
                post: function postLink(scope, elem, attrs) {
                    var element = "#discussion-element-"+ attrs.elementId;
                    var myEl = angular.element( document.querySelector( element) );
                    var height = myEl[0].offsetHeight;
                    element.height(height);
                }
            }
        }
    };
});

Image that illustrate the issue:

enter image description here

jirikuchta

Try removing the float: left style and applying these styles instead:

.parent {
    display: table;
}

.parent > * {
    display: table-cell;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Take in parent divs (dynamic) height, and set child div to same height

From Dev

Vertically align a child div element with parent div having dynamic height

From Dev

while setting the span element height as 100% it is not set as parent Div height

From Dev

How to set a 'div' height same with his neighbor?

From Dev

How to set a 'div' height same with his neighbor?

From Dev

Set height to child div to match parent in > Angular 2

From Dev

Parent div's height is larger than his children

From Dev

Parent div's height is larger than his children

From Dev

Div not inheriting height of parent element

From Dev

jQuery set height of a div to the 'dynamic height' of another

From Dev

center an element within a dynamic height and width parent

From Dev

How to set a div to fill the space remaining in his parent (horizontally)?

From Dev

Set div 50% height of parent div

From Dev

Child DIV with dynamic height and absolute position - Give height to parent DIV

From Dev

No height on parent div with dynamic elements created inside

From Dev

Set child of flex element to be height of parent?

From Java

Stretch child div height to fill parent that has dynamic height

From Dev

Set parent div height to content that is not overflowing

From Dev

Height of div element not matching parent's height when 100%

From Dev

How to set height of parent, dependent on height of selected element

From Dev

Make parent div height dynamic which choose child div?

From Dev

How to get div height of his parent while using d-flex in Bootstrap

From Dev

Get the Height of a child div data attribute and then set the Height of the Parent

From Dev

How to set child div border to parent div height

From Dev

How to set parent div's height as child div with position: absolute

From Dev

Div disappears when absolute positioned, parent dynamic height

From Dev

Div disappears when absolute positioned, parent dynamic height

From Dev

How to set content area div height with dynamic header div

From Dev

How to set content area div height with dynamic header div

Related Related

  1. 1

    Take in parent divs (dynamic) height, and set child div to same height

  2. 2

    Vertically align a child div element with parent div having dynamic height

  3. 3

    while setting the span element height as 100% it is not set as parent Div height

  4. 4

    How to set a 'div' height same with his neighbor?

  5. 5

    How to set a 'div' height same with his neighbor?

  6. 6

    Set height to child div to match parent in > Angular 2

  7. 7

    Parent div's height is larger than his children

  8. 8

    Parent div's height is larger than his children

  9. 9

    Div not inheriting height of parent element

  10. 10

    jQuery set height of a div to the 'dynamic height' of another

  11. 11

    center an element within a dynamic height and width parent

  12. 12

    How to set a div to fill the space remaining in his parent (horizontally)?

  13. 13

    Set div 50% height of parent div

  14. 14

    Child DIV with dynamic height and absolute position - Give height to parent DIV

  15. 15

    No height on parent div with dynamic elements created inside

  16. 16

    Set child of flex element to be height of parent?

  17. 17

    Stretch child div height to fill parent that has dynamic height

  18. 18

    Set parent div height to content that is not overflowing

  19. 19

    Height of div element not matching parent's height when 100%

  20. 20

    How to set height of parent, dependent on height of selected element

  21. 21

    Make parent div height dynamic which choose child div?

  22. 22

    How to get div height of his parent while using d-flex in Bootstrap

  23. 23

    Get the Height of a child div data attribute and then set the Height of the Parent

  24. 24

    How to set child div border to parent div height

  25. 25

    How to set parent div's height as child div with position: absolute

  26. 26

    Div disappears when absolute positioned, parent dynamic height

  27. 27

    Div disappears when absolute positioned, parent dynamic height

  28. 28

    How to set content area div height with dynamic header div

  29. 29

    How to set content area div height with dynamic header div

HotTag

Archive