Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

HTML & CSS Align form vertically

SpongeBOB

Well-Known Coder
Hi everyone,

I would like to display 4 little form side by side (with a space / gap between them)

For now I have this


[CODE lang="html" title="HTML"]<form method = "POST" >
<input type="hidden" name="langue" value="en">
<input type="image" src="static/us.gif" title="English">
</form>

<form method = "POST" >
<input type="hidden" name="langue" value="fr">
<input type="image" src="static/fr.gif" title="French">
</form>

<form method = "POST" >
<input type="hidden" name="langue" value="nl">
<input type="image" src="static/nl.gif" title="Dutch">
</form>

<form method = "POST" >
<input type="hidden" name="langue" value="pl">
<input type="image" src="static/pl.gif" title="Polish">
</form>[/CODE]

the output is :
2021-05-13-0724.png
I've tried to edit my CSS ->

CSS:
<style>
form {
 float: left;
}   
</style>

the output is:
2021-05-13-0726.png
Almost there but now I need a space between them...

Thanks.
 
Almost there...

Now I have this

2021-05-13-0741.png

here My CSS & HTML

CSS:
form {
 float: left;
 margin-right: 10px;
}

HTML:
<div>

<form method = "POST" >
<input type="hidden" name="langue" value="en">
<input type="image" src="static/us.gif" title="English">
</form>

<form method = "POST" >
<input type="hidden" name="langue" value="fr">
<input type="image" src="static/fr.gif" title="French">
</form>

<form method = "POST" >
<input type="hidden" name="langue" value="nl">
<input type="image" src="static/nl.gif" title="Dutch">
</form>

<form method = "POST" >
<input type="hidden" name="langue" value="pl">
<input type="image" src="static/pl.gif" title="Polish">
</form>

</div>


<pre>
blablablabla
</pre>

How can I place the text under the form and not to the right (in-line) ?
Thanks.
 
Why not flex-box -
HTML:
<!DOCTYPE html>

<html>

<head>
    <meta charset="UTF-8">
    <title>Test</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .first {
            display: flex;
        }

        .first > form {
            padding: 5px 10px 10px 5px;
            background-color: #000;
        }

        .pre {
            margin: 10px;
        }
    </style>
</head>

<body>
    <div class="first">
        <form method = "POST" >
            <input type="hidden" name="langue" value="en">
            <input type="image" src="static/us.gif" title="English">
        </form>

        <form method = "POST" >
            <input type="hidden" name="langue" value="fr">
            <input type="image" src="static/fr.gif" title="French">
        </form>

        <form method = "POST" >
            <input type="hidden" name="langue" value="nl">
            <input type="image" src="static/nl.gif" title="Dutch">
        </form>

        <form method = "POST" >
            <input type="hidden" name="langue" value="pl">
            <input type="image" src="static/pl.gif" title="Polish">
        </form>
    </div>

    <div class="pre">
        blablablabla blablablabla blablablabla blablablabla blablablabla blablablabla
    </div>

</body>

</html>
 

Attachments

  • AlignVerticaly.jpg
    AlignVerticaly.jpg
    22.7 KB · Views: 1

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom