Unlike <h2>Personal information<h2>
which shows perfectly how I want it to show the <h2>Emergency contact<h2>
header that gets misplaced on the page.
The CSS for <h2>
is on the CSS folder below:
<section class="personal-info">
<h2>PERSONAL INFORMATION</h2>
<form>
@*get firstname and last name to alighn with the other textboxes also make them fill the page*@
<label for="FirstName">First Name</label>
@Html.TextBoxFor(x => x.FirstName, new { @class = "form-control", id = "FirstName", placeholder = "Enter First Name" })
<div class="form-row col-lg-10">
<label for="LastName">Last Name</label>
@Html.TextBoxFor(x => x.LastName, new { @class = "form-control", id = "LastName", placeholder = "Enter Last Name" })
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="ID_Number">ID Number</label>
@Html.TextBoxFor(x => x.ID_Number, new { @class = "form-control", id = "ID_Number", placeholder = "Enter ID Number" })
</div>
<div class="form-group col-md-6">
<label for="DateOfBirth">Date Of Birth</label>
@Html.TextBoxFor(x => x.DateOfBirth, "{0:dd/MM/yyyy}", new { @class = "form-control datepicker", id = "DateOfBirth", placeholder = "DD/MM/YYYY" })
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="dllGetGender">Gender</label>
@Html.DropDownListFor(x => x.GenderIDFK, new List<SelectListItem>(), "Select Gender", new { @class = "form-control", id = "dllGetGender" })
</div>
<div class="form-group col-md-6">
<label for="dllPhoneNumber">Phone Number</label>
@Html.TextBoxFor(x => x.PhoneNumber, new { @class = "form-control", id = "dllPhoneNumber", placeholder = "Enter Phone Number" })
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="dllEmail">Email</label>
@Html.TextBoxFor(x => x.Email, new { @class = "form-control", id = "dllEmail", placeholder = "Enter Email" })
</div>
<div class="form-group col-md-6">
<label for="dllLine1">Address Line 1</label>
@Html.TextBoxFor(x => x.Line1, new { @class = "form-control", id = "dllLine1", placeholder = "Enter Address Line 1" })
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="dllLine2">Address Line 2</label>
@Html.TextBoxFor(x => x.Line2, new { @class = "form-control", id = "dllLine2", placeholder = "Enter Address Line 2" })
</div>
<div class="form-group col-md-6">
<label for="dllGetCities">City</label>
@Html.DropDownListFor(x => x.CityIDFK, new List<SelectListItem>(), "Select City", new { @class = "form-control", id = "dllGetCities" })
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="dllGetProvinces">Province</label>
@Html.DropDownListFor(x => x.ProvinceIDFK, new List<SelectListItem>(), "Select Province", new { @class = "form-control", id = "dllGetProvinces" })
</div>
<div class="form-group col-md-6">
<label for="dllGetCountries">Country</label>
@Html.DropDownListFor(x => x.CountryIDFK, new List<SelectListItem>(), "Select Country", new { @class = "form-control", id = "dllGetCountries" })
</div>
</div>
</form>
</section>
<hr />
<section class="emergancy-contact">
@*get h2 to give only they emergancy contact color *@
<h2>emergancy contact</h2>
<form>
<div class="form-row">
<div class="form-group col-md-6">
<label for="dllGetMaritalStatus">Marital Status</label>
@Html.DropDownListFor(x => x.MaritalStatusIDFK, new List<SelectListItem>(), "Select Marital Status", new { @class = "form-control", id = "dllGetMaritalStatus" })
</div>
<div class="form-group col-md-6">
<label for="dllEmergencyName">Emergency Name</label>
@Html.TextBoxFor(x => x.EmergencyName, new { @class = "form-control", id = "dllEmergencyName", placeholder
= "Enter Emergency Contact Name" })
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="dllEmergencyLastName">Emergency Last Name</label>
@Html.TextBoxFor(x => x.EmergencyLastName, new { @class = "form-control", id = "dllEmergencyLastName", placeholder = "Enter Emergency Contact Last Name" })
</div>
<div class="form-group col-md-6">
<label for="dllEmergencyPhoneNumber">Emergency Phone Number</label>
@Html.TextBoxFor(x => x.EmergencyPhoneNumber, new { @class = "form-control", id = "dllEmergencyPhoneNumber", placeholder = "Enter Emergency Contact Phone" })
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="dllRelationship">Relationship</label>
@Html.TextBoxFor(x => x.Relationship, new { @class = "form-control", id = "dllRelationship", placeholder = "Enter Relationship" })
</div>
<div class="form-group col-md-6">
<label for="dllEmergancyDateOfBirth">Emergency Contact DOB</label>
@Html.TextBoxFor(x => x.EmergancyDateOfBirth, "{0:dd/MM/yyyy}", new { @class = "form-control datepicker", id = "dllEmergancyDateOfBirth", placeholder = "DD/MM/YYYY" })
</div>
</div>
</form>
</section>
The following is the CSS code:
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f0f0f0;
}
.form-container {
width: 70%;
margin: 30px auto;
background-color: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
header {
background-color: #00796b;
padding: 20px;
color: white;
text-align: center;
}
.header-content {
display: flex;
justify-content: space-between;
align-items: center;
}
.logo img {
width: 100px;
}
.title h1 {
font-size: 24px;
color: #fff;
}
h2 {
background-color: #004d40;
color: white;
padding: 10px;
font-size: 18px;
}
form {
margin: 20px 0;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input, select, textarea {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 4px;
}
input[type="radio"] {
width: auto;
margin-right: 10px;
}
textarea {
height: 100px;
}
footer {
margin-top: 30px;
text-align: center;
}
footer p {
font-weight: bold;
}
address {
font-style: normal;
}
.signature p {
font-size: 18px;
font-style: italic;
margin-top: 10px;
}
2
Answers
In order to solve this we are going to need a runnable snippet. Here is a runnable snippet I derived from your template code, but it doesn’t seem to replicate the problem. I suggest that you copy this snippet into your post and then edit it until it replicates the problem.
Try to change this
to this:
col-lg-10
leaves some space (2 columns in the 12 column system) on the rigth side, to which the first word of the secondh2
apparently "slips up". Filling the complete space (usingcol-lg-12
) might fix that.