hey i am trying to have this invalid-deefback at bottom of input field and not to bottom…
- User
hey i am trying to have this invalid-deefback at bottom of input field and not to bottom of label one how to do that? how to align below input field?
<div class="invalid-feedback ps-0 ps-md-2 ">Case Type can't be empty</div> </div> - Assistant
To align the invalid feedback message directly below the input field instead of the label, you can adjust your HTML structure and possibly your CSS. The key is to place the invalid feedback message inside the same flex container but after the input field.
Here's how you can update your code:
<div class="col-12 col-md-6 fs-5 d-flex flex-column justify-content-center align-items-start my-2 my-sm-3 my-lg-4 row mx-0 px-4 px-md-4"> <label for="caseTypeInput" class="m-1 m-md-2 col-12 col-sm-auto text-start pe-2 ps-0"> Case Type </label> <input name="caseTypeInput" id="caseTypeInput" type="text" class="p-2 border rounded col" required> <div class="invalid-feedback ps-0 ps-md-2">Case Type can't be empty</div> </div>Changes Made:
-
Flex Direction: Change the
d-flextod-flex flex-column, which creates a vertical stack of elements. This way, now the invalid feedback will appear directly under the input field.
-
- User
if i do that input field will be at bottom of label and i dont want that
- Assistant
If you want the label to be above the input field and the invalid feedback to be directly below the input field, while keeping the layout organized, you can structure your HTML like this:
<div class="col-12 col-md-6 fs-5 my-2 my-sm-3 my-lg-4 row mx-0 px-4 px-md-4"> <label for="caseTypeInput" class="m-1 m-md-2 col-12 text-start pe-2 ps-0"> Case Type </label> <div class="d-flex flex-column"> <input name="caseTypeInput" id="caseTypeInput" type="text" class="p-2 border rounded" required> <div class="invalid-feedback ps-0">Case Type can't be empty</div> </div> </div>Explanation of the Structure:
-
Flex Column Wrapper: Add a
divwithclass="d-flex flex-column"to wrap around the input field and the invalid feedback message. This keeps them stacked vertically while allowing the label to remain above the input field. -
Label Location: The label is placed directly inside the parent , ensuring that it appears above the input field.
-