As I work with a div html tag within a login form, encountering an error inside this form has presented a challenging issue. The error div sits at the top of its parent div, and ideally, upon activation, should remain within the form div without disrupting its position or size. Implementing position: absolute
in the child div only resulted in it remaining fixed at the left corner of the parent div. Using z-index
did not prevent the parent div from shifting by the height of the child div. The following code snippet illustrates this scenario:
<div id='formulario' style={{height: 400px}}>
{this.props.auth.error && <div id='erro' style={{height:'15px'}}>Nao foi possivel fazer o login!</div>}
<div id='login'>
...
</div>
</div>
Upon validation of this.props.auth.error
, the error message displays causing the form to expand to 415px. How can I ensure that the #formulatrio
div stays at a size of 400px
while keeping the #login
div intact when the error is triggered?