javascript - 将文本和表单放置在彼此平行的位置(并排)- HTML

标签 javascript html css

我正在尝试将表格和一些段落文本并排放置在左侧,以便它们彼此平行,但我不明白如何做到这一点

目前我正在尝试将表单向右浮动,但是社交图标随后会从底部移动到屏幕左侧

我想并排放置 ids: "myForm"和类 "info" 代码:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Arshdeep Soni</title>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width, inital-scale=1">

        <link rel="stylesheet" type="text/css" href="reset.css"/>
        <link rel="icon" type="image/png" href="images/ace.png"/>
        <link rel="stylesheet" type="text/css" href="style.css"/>
        <script type="text/javascript" src="js/jquery.js"></script>

        <script type="text/javascript" src="script.js">
        </script>

        <style type="text/css">
            body {
                background-color: black;
                background-image: url();
                color:white;
                font-family: sans-serif;
            }

            #name {
                color:white;
                font-family: coolvetica;
                font-size: 50px;
                text-align: center;
                padding-top: 60px;
                letter-spacing: 6px;
                font-weight: bolder;
                text-transform: uppercase;
            }

            #magician {
                color:white;
                font-family: raleway;
                font-size: 25px;
                letter-spacing: 11px;
                margin-top: 2%;
                text-align: center;
            }

            hr {
                border: 0;
                height: 1px;
                background: #333;
                background-image: -webkit-linear-gradient(left, #ccc, #ffffff, #ccc);
                background-image:    -moz-linear-gradient(left, #ccc, #ffffff, #ccc);
                background-image:     -ms-linear-gradient(left, #ccc, #ffffff, #ccc);
                background-image:      -o-linear-gradient(left, #ccc, #ffffff, #ccc);

                width:50%;
                max-width: 100%;
            }

            #info {
            }

            #info h2 {
                color:white;
                font-family: Baron neue;
                font-size: 30px;
                padding: 30px 0px 0px 10px;
                margin-right: 50%;
            }

            #info p {
                font-family: sans-serif;
                font-size: 15px;
                padding-top: 10px;
                padding-left: 10px;
                margin-right: 50%;
            }

            #contact {
                padding-left: 10px;
                line-height: 1.7em;
                margin-right: 50%;
            }

            #myForm {
                top:0;
                float:right;
            }

        </style>

    </head>

    <body>

        <div class="header">
        </div>                    
        <span class="menu-Trigger" align="center" >&#9776; Menu</span>
        <div class="nav-menu">
            <ul>
                <li><a href="index.html">HOME</a></li>
                <li><a href=#>VIDEOS</a></li>
                <li><a href=#>IMAGES</a></li>
                <li><a href=#>EVENTS</a></li>
                <li><a href=#>TESTIMONIALS</a></li>
                <li class="current"><a href="Contact.html">ENQUIRIES</a></li>
            </ul>
        </div>

        <h1 id="name">Arshdeep Soni</h1>
        <p id="magician">Magician</p>
        <hr>


        <div id="info">
            <h2>Enquiries</h2>
            <p id="contact">Phone: (+44)</p>
            <email id="contact">Email: Bookings@ArshdeepSoni.com</email>
            <p id="i"> For bookings please fill out the form below or email <a style="color:#01b2b2; text-decoration:none;"href="mailto: Bookings@ArshdeepSoni.com?" target="_top"> Bookings@ArshdeepSoni.com</b></a> and we will endeavour to get back to you within 48 hours.</p>

            <form id="myForm" method="post" action="Contact.html" onsubmit="#"> 
                <p>Your Name: </p>
                <input type="text" name="name"/>
                <p>Subject: </p>
                <input type="text" name="subject"/></br>
                <p>Your Email: </p>
                <input type="text" name="email"/></br>
                <p>Phone Number: </p>
                <input type="text" name="number"/></br>
                <p>Message: </p>
                <textarea id="message"></textarea>
                <input type="submit" value="Send"/>
            </form>
        </div>

        <div class="main">
        </div>

        <div class="icons">
                <a class="socialIcons" href="http://www.youtube.com" title="Subscribe on YouTube" alt="Arshdeep on YouTube"><img src="images/social/youtube.png"/></a>
        <a class="socialIcons" href="http://www.instagram.com/ArshSoni" title="Subscribe!" alt="Arshdeep Soni"><img src="images/social/instagram.png" /></a>
<a class="socialIcons" href="http://www.facebook.com/MagicArsh" title="Arshdeep Soni on Facebook" alt="Facebook"><img src="images/social/fb.png" /></a>
                <a class="socialIcons" href="http://twitter.com/ArshSoni" title="Follow Arshdeep on Twitter" alt="Twitter"><img src="images/social/twitter.png" /></a>
        </div>
    </body>
</html>

最佳答案

你应该像这样将“myForm”移到“info”div 之外

    <div id="info">
        <h2>Enquiries</h2>
        <p id="contact">Phone: (+44)</p>
        <email id="contact">Email: Bookings@ArshdeepSoni.com</email>
        <p id="i"> For bookings please fill out the form below or email <a style="color:#01b2b2; text-decoration:none;"href="mailto: Bookings@ArshdeepSoni.com?" target="_top"> Bookings@ArshdeepSoni.com</b></a> and we will endeavour to get back to you within 48 hours.</p>
    </div>

    <form id="myForm" method="post" action="Contact.html" onsubmit="#"> 
        <p>Your Name: </p>
        <input type="text" name="name"/>
        <p>Subject: </p>
        <input type="text" name="subject"/></br>
        <p>Your Email: </p>
        <input type="text" name="email"/></br>
        <p>Phone Number: </p>
        <input type="text" name="number"/></br>
        <p>Message: </p>
        <textarea id="message"></textarea>
        <input type="submit" value="Send"/>
    </form>

这些元素的 CSS 应如下所示

#myForm {
    display:inline-block;
}
#info {
    width: 50%;  // Adjust to your liking
    float:left;
}

https://jsfiddle.net/srf9w1w3/

关于javascript - 将文本和表单放置在彼此平行的位置(并排)- HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30224187/

相关文章:

javascript - 如何使用未知内容和固定布局垂直居中内容

javascript - 包含按钮错误 : I would a button every 8 elements of the list 的列表

javascript - 如何聚合 Node.js 流回调中异步函数生成的 Promise?

javascript - 如何使用scrapy或selenium抓取动态页面?

javascript - 如何在 Bootstrap 中将单选按钮设置为 "checked"?

css - 如何在CSS中的每条推文之前添加一个空格

html - 使用CSS在背景图像中居中文本

javascript - 替代 jquery ui

html - 需要将列表项与 div 的中心对齐

javascript - 使用 javascript/jquery 创建动态 div