I am just trying to understand how to use position relative and absolute. From my understanding so far, I know that position relative will put the element in its normal flow but for a following form, should my main title be positioned relative or absolute? I found that if I made it positioned relative, certain things such as the labels need to be positioned absolute to move around things but if I put the title as positioned absolute, then the label would need to be in positioned relative to have the same effect..... Hope someone could clarify this for me
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="practice_diary_title">
<h2>Welcome to your practice diary section!</h2>
</div>
<div class="practice_diary">
<form class="signup-form" action="practice_diary_form.php" method="POST">
<label>Username:</label>
<br></br>
<input text="text" name="user_uid" placeholder="Username">
<br></br>
<label>Student's First Name:</label>
<br></br>
<input text="text" name="first_name" placeholder="Student's First Name">
<br></br>
<label>Student's Last Name:</label>
<br></br>
<input text="text" name="last_name" placeholder="Student's Last Name">
<br></br>
<label>Lesson Title:</label>
<br></br>
<input text="text" name="lesson_title" placeholder="Lesson Title">
<br></br>
<label class="describe_lesson">Describe Lesson: For example: Did you practice counting? fingering?</label>
<br></br>
<div class="practice_diary_text">
<textarea name="describe_lesson" placeholder="Describe Lesson"></textarea>
</div>
<br></br>
<div class="practice_diary_last_two_questions">
<label>Hours of practice:</label>
<br></br>
<input text="text" name="hours_practice" placeholder="Hours of Practice">
<br></br>
<label>Date of Practice:</label>
<br></br>
<input text="text" placeholder="<?php echo htmlspecialchars($date); ?>">
<br></br>
</div>
<button type="submit" name="submit">Enter Diary</button>
</form>
</div>
This is my CSS code and I found it easier to place the label positioned the opposite of what I have for the div.practice_diary... I know that I am trying to understand a lot but are there things that is happening without a reason? I just feel that I am trying to understand too much and should just accept that it is working....
div.practice_diary {
position: absolute;
top: 118em;
right: 55em;
}
div.practice_diary input {
height: 40px;
padding: 0px 5%;
margin-bottom: 4px;
border-radius: 10px solid black;
background-color: #fff;
font-family: arial;
font-size: 16px;
color: #111;
display: inline-block;
width: 300px;
}
div.practice_diary input::placeholder{
color: #6A5ACD ;
opacity: 1;
position: relative;
left: .5em;
font-size: 1em;
}
div.practice_diary label {
color:#008000;
font-size: 1.5em;
white-space: nowrap;
position: absolute;
left: -2em;
margin-top: -1em;
}
div.practice_diary textarea {
width: 40em;
height:8em;
position: absolute;
margin-top: 1em;
font-size: 1em;
}
div.practice_diary textarea::placeholder {
color: #6A5ACD ;
opacity: 1;
position: relative;
right: -1em;
font-size: 1.2em;
}
div.practice_diary_last_two_questions input {
position: relative;
top: 9em;
}
div.practice_diary_last_two_questions label {
color:#008000;
font-size: 1.5em;
white-space: nowrap;
position: relative;
display: block;
left: -2em;
top: 7em;
}