I have written a contact form about php. I would like the input fields and the text output to be centered. Since I created the input fields with the form tag, I thought it would be sufficient if I insert the centering in the CSS file with the form tag. However, the place ignores the CSS file (all other settings on the page work above the CSS file). What could be the reason?
I've already tried .form, #form and only form, but has no effect
CSS:
form {
width:300px;
height:160px;
position:absolute;
top:50%;
left:50%;
margin-top:-80px;
margin-left:-150px;
border:1px solid black;
}
HTML:
<head>
<link rel="stylesheet" href="css/style.css">
</head>
<form action="" method="post">
<input type="text" name="betreff" placeholder="Betreff?"><br>
<textarea name="nachricht" placeholder="Ihre Nachricht!">
</textarea><br>
<input type="submit" name="submit" value="Absenden!"><br>
</form>
PHP:
<?php
if(isset($_POST['submit'])):
$betreff = $_POST['betreff'];
$nachricht = $_POST['nachricht'];
$absenden = $db->prepare("INSERT INTO kontakt(betreff,nachricht,datum) VALUES (?,?,NOW())");
$absenden->bind_param('ss',$betreff,$nachricht);
$absenden->execute();
endif;
$abfrage = $db->query("SELECT * FROM kontakt ORDER BY datum DESC");
echo 'Es wurden '.$abfrage->num_rows.' Nachrichten gefunden!<br>';
while($ausgabe = $abfrage->fetch_object()){
echo '<b>Betreff:</b> '.$ausgabe->betreff.' <br>
<b>Nachricht:</b><br> '.$ausgabe->nachricht.' <br>
<hr>';
}
Actually I would like to have the contact form in the middle, but I would be glad if he would react to the CSS statement at all. As already said, only the contact form is left out. The rest works.