How to put this form below the header?

Asked

Viewed 118 times

1

I’m starting now to study HTML, someone knows how to put the form I created below Header?

h1 {
  text-align: center;

}


/* caixa header */

.headerbox {
	padding: 30px;
  background: blue;
  color: white;
  text-align: center;
  position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);


}


body{
background: #396afc;  /* fallback for old browsers */
background: -webkit-linear-gradient(to left, #2948ff, #396afc);  /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to left, #2948ff, #396afc); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */

}
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8"/>
    	 <title>Document</title>
    	 <link rel="stylesheet" href="css/style.css">
 	</head>
 
 	<body>
     <!-- Conteúdo -->


	<header>
		<div class="headerbox">
  		<h1>Este é o título do site.</h1>
  		<p1>essa é uma chamada para o site.</p1>
 		</div>
	</header>


	<form action="/pagina-processa-dados-do-form" method="post">
    <div>
        <label for="nome">Nome:</label>
        <input type="text" id="nome" />
    </div>
    <div>
        <label for="email">E-mail:</label>
        <input type="email" id="email" />
    </div>
    <div>
        <label for="msg">Mensagem:</label>
        <textarea id="msg"></textarea>
    </div>
</form>



 </body>
</html>

1 answer

0

First you need to abuse HTML5 semantics to organize your content. Usually, the tag <header> is in the header of the site.

Think of an Organization of the main tags:

  • header: Top of the site (Where menus are usually located and among other navigations);
  • main: where your form will really be;
  • footer: Where is the bottom of the application;
  • Section: generally, it is inside the main of your page, where there can be several, put your form here inside, for example!
  • article: If you have valuable content, play this content inside the article, which may also have sections inside it. It is inside Main.

Now, come on! Each tag of this, a BLOCK that goes from one end of the interface to another. Unless you model.

So your form should look like this:

Follow example in codepen: https://codepen.io/codenome/pen/xmdpJd

<main>
  <section>
      <div class="headerbox">
          <h1>Este é o título do site.</h1>
          <p1>essa é uma chamada para o site.</p1>
    </div>
    <div class="both">
          <form action="/pagina-processa-dados-do-form" method="post">
            <div>
                <label for="nome">Nome:</label>
                <input type="text" id="nome" />
            </div>
            <div>
                <label for="email">E-mail:</label>
                <input type="email" id="email" />
            </div>
            <div>
                <label for="msg">Mensagem:</label>
                <textarea id="msg"></textarea>
            </div>
        </form>
      </div>
  </section>
</main>

Be sure to add the Both class:

.both {
  position: absolute;
    left: 50%;
    top: 65%;
    transform: translate(-50%, -50%);
}
  • 1

    Thank you! But I want to put the form out of the box I created, under it. You know how I do it?

  • I saved there! Check the link again, please.

  • 2

    Hello. Edit the answer and enter the code here in Sopt. For here is a world for it. Greetings.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.