Hello everyone,
I am trying to build an HTML/CSS form from scratch.
However, I want to bring the legend within the fieldset rather then the legend sitting on the fieldset.
To get this done, I gave the fieldset a top padding and the legend an absolute position. However the fieldset appeared to have a break as indicated in the red circle of the below image. How can I close or prevent this gap/break?
Here is the complete code.
<style type="text/css">
form{
margin: 0;
padding: 0;
font-family: "Century Gothic";
font-weight: bold;
font-size: 16px;
}
legend span{
position: absolute;
top: 30px;
}
fieldset{
background-color: #EAEAEA;
padding-top: 60px;
}
div{
width: 100%;
margin: 0 0 5px 0;
padding: 0;
}
label {
float: left;
width: 160px;
margin-right: 16px;
text-align: right;
margin-top: 5px;
}
.UserFirstNameField, .UserLastNameField, .UserEmailField, .UserPhoneNumberField{
width: 200px;
padding: 4px;
font-family: "Century Gothic";
font-weight: bold;
font-size: 16px;
color: #F90;
background-image: url(DFormsImages/Form-Fields-Background-Image.png);
background-repeat: repeat-x;
background-position: left center;
border: 1px solid #D5D5D5;
}
</style>
<!--[if lte IE 7]>
<style type="text/css" media="all">
label {
margin-top: 5px;
}
</style>
<![endif]-->
</head>
<body>
<form id="BasicForm" class="BasicFormTemplate" method="post" action="">
<fieldset>
<legend><span>Personal Information</span></legend>
<div>
<label for="UserFirstName">First Name:</label>
<input id="FirstNameInput" name="UserFirstName" class="UserFirstNameField" type="text" />
</div>
<div>
<label for="UserLastName">Last Name:</label>
<input id="LastNameInput" name="LastName" class="UserLastNameField" type="text" />
</div>
<div>
<label for="UserEmail">Email:</label>
<input id="UserEmailInput" name="UserEmail" class="UserEmailField" type="text" />
</div>
<div>
<label for="UserPhoneNumber">Phone Number:</label>
<input id="UserPhoneNumberInput" name="UserPhoneNumber" class="UserPhoneNumberField" type="text" />
</div>
</fieldset>
</form>
</body>
</html>
Thanks everyone!
IC