Как сдвинуть форму в HTML ниже?

Как сдвинуть форму "Range of ports" ниже?

const sendMessage = () => {
        alert('Please wait for the scanning!');
    }
html {
            font-family: Verdana, "sans-serif";
        }

        body {
            min-height: 100vh;
            background: black no-repeat;
        }

        h1 {
            text-align: center;
            color: white;
            text-shadow: 0 3px 5px rgba(150, 150, 150, 0.8);
        }

        #root {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        #messages {
            width: 70%;
        }

        .message {
            background-color: white;
            width: 100%;
            padding: 20px;
            border-radius: 10px;
            -webkit-transition: 0.3s;
            -moz-transition: 0.3s;
            transition: 0.3s;
            -webkit-box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
            -moz-box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
            box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
            box-sizing: border-box;
            margin-bottom: 10px;
        }

        .message:hover {
            -webkit-transition: 0.3s;
            -moz-transition: 0.3s;
            transition: 0.3s;
            -webkit-box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
            -moz-box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
            box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
        }

        .message__created {
            font-size: 12px;
            color: darkgrey;
            text-align: right;
        }

        .message__text {
            font-size: 20px;
            color: black;
            margin-top: 5px;
        }

        .message__ratings {
            display: flex;
            justify-content: space-between;
            font-size: 16px;
            font-weight: 400;
            margin-top: 5px;
        }

        .form {
            width: 70%;
            margin-bottom: 20px;
        }

        .form__button {
            text-align: center;
            margin-top: 150px;
            background-color: white;
            cursor: pointer;
        }

        .form__input, .form__button {
            box-sizing: border-box;
            width: 100%;
            font-size: 18px;
            outline: none;
            border: none;
            padding: 20px;
            border-radius: 15px;
            -webkit-transition: 0.3s;
            -moz-transition: 0.3s;
            transition: 0.3s;
            -webkit-box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
            -moz-box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
            box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
        }

        .form__input:focus, .form__button:hover {
            -webkit-transition: 0.3s;
            -moz-transition: 0.3s;
            transition: 0.3s;
            -webkit-box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
            -moz-box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
            box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
        }
<div>
    <h1>Port Scanner</h1>
    <div id="root">
        <div class="form">
            <input id="message_text" class="form__input" type="text"
                   placeholder="IP adress"/>
            <input id="message_text1" class="form__input" type="text"
                   placeholder="Range of ports"/>
            <div class="form__button" onclick="sendMessage()">Scan</div>
        </div>
        <div id="messages">

        </div>
    </div>
</div>


Ответы (1 шт):

Автор решения: novvember
  1. Используйте flex внутри формы, чтобы расположить элементы внутри. Тогда управлять располжением элементов будет очень просто. Я выставил gap: 20px для формы.

  2. Используйте тег button, когда вставляете кнопки. А для формы так <button type="submit">Кнопка</button>

  3. Для всей формы используйте тег <form>.

const sendMessage = () => {
        alert('Please wait for the scanning!');
    }
html {
            font-family: Verdana, "sans-serif";
        }

        body {
            min-height: 100vh;
            background: black no-repeat;
        }

        h1 {
            text-align: center;
            color: white;
            text-shadow: 0 3px 5px rgba(150, 150, 150, 0.8);
        }

        #root {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        #messages {
            width: 70%;
        }

        .message {
            background-color: white;
            width: 100%;
            padding: 20px;
            border-radius: 10px;
            -webkit-transition: 0.3s;
            -moz-transition: 0.3s;
            transition: 0.3s;
            -webkit-box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
            -moz-box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
            box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
            box-sizing: border-box;
            margin-bottom: 10px;
        }

        .message:hover {
            -webkit-transition: 0.3s;
            -moz-transition: 0.3s;
            transition: 0.3s;
            -webkit-box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
            -moz-box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
            box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
        }

        .message__created {
            font-size: 12px;
            color: darkgrey;
            text-align: right;
        }

        .message__text {
            font-size: 20px;
            color: black;
            margin-top: 5px;
        }

        .message__ratings {
            display: flex;
            justify-content: space-between;
            font-size: 16px;
            font-weight: 400;
            margin-top: 5px;
        }

        .form {
            width: 70%;
            margin-bottom: 20px;
            
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .form__button {
            text-align: center;
            margin-top: 150px;
            background-color: white;
            cursor: pointer;
        }

        .form__input, .form__button {
            box-sizing: border-box;
            width: 100%;
            font-size: 18px;
            outline: none;
            border: none;
            padding: 20px;
            border-radius: 15px;
            -webkit-transition: 0.3s;
            -moz-transition: 0.3s;
            transition: 0.3s;
            -webkit-box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
            -moz-box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
            box-shadow: 0px 5px 5px 0px rgba(0, 0, 0, 0.1);
        }

        .form__input:focus, .form__button:hover {
            -webkit-transition: 0.3s;
            -moz-transition: 0.3s;
            transition: 0.3s;
            -webkit-box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
            -moz-box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
            box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
        }
<div>
    <h1>Port Scanner</h1>
    <div id="root">
        <form class="form" onsubmit="sendMessage()">
            <input id="message_text" class="form__input" type="text"
                   placeholder="IP adress"/>
            <input id="message_text1" class="form__input" type="text"
                   placeholder="Range of ports"/>
            <button class="form__button" type="submit">Scan</button>
        </form>
        <div id="messages">

        </div>
    </div>
</div>

→ Ссылка