0

i tried creating form with fields side by side using divs .But they are diplayed one after another in rows. here i am getting batchcode and coursecode intwo rows .How to get them in a single row side by side.

<!DOCTYPE html>
<html>  
    <head>

        <link href="css/reset.css" media="screen" rel="stylesheet"/>
        <link href="css/redmond/jquery-ui-1.10.2.custom.min.css" media="screen" rel="stylesheet"/>
        <link href="css/default.css" media="screen" rel="stylesheet"/>
        <link href="sidebarmenu.css" rel="stylesheet" type="text/css">
                <script src="sidebarmenu.js"></script>
                <script src="scripts/jquery-1.9.1.min.js"></script> 
        <script src="scripts/jquery-ui-1.10.2.custom.min.js"></script> 

</head>
    <body>  

        <!--<form id="frmExamRegistration" method="post" enctype="multipart/form-data" class="anu">-->


    <form name="f1" method="post" class="anu">  
    <%@include file="header.html"%>

<div  style="float:right;width:10%;border:0;font-color:#163362"><a href=logout.jsp">Log Out</a></div>
<%@include file="sidemenus.jsp" %>

    <div id="container">
        <div class="content"  ><center>Delete Batch</center><br>
            <div class="formElements">
                <label>Batch code:</label>
                 <span><input type="text" id="txtBatchcode" name="txtBatchcode" ></span>

            <div class="formElements" style="z-index:-1">
                <label>Course Code:</label>
                 <span><input type="text" id="txtCoursecode" name="txtCoursecode" ></span>

            <div class="buttons" align="center">
                <button type="submit" class="primaryAction">Delete</button>
                                <button type="reset" class="primaryAction">Clear</button>

            </div></div></div>
                 </div>
         </div>
       </form>
  </body>
</html>
4

4 回答 4

0

您可以使用表来做到这一点:

 <form name="f1" method="post" class="anu">
    <div style="float:right;width:10%;border:0;font-color:#163362">
        <a href=logout.jsp ">Log Out</a></div>


    <div id="container ">
        <div class="content "  ><center>Delete Batch</center><br>

    <table>
        <tr>
            <td>
                <label>Batch code:</label> <span><input type="text " id="txtBatchcode " name="txtBatchcode " ></span>

            </td>
            <td>
                <label>Course Code:</label> <span><input type="text " id="txtCoursecode " name="txtCoursecode " ></span>

            </td>
        </tr>
        </table>
        </div>
        </div>

</form>

演示

使用表格是最简单的方法。您根本不必使用CSS

于 2013-04-03T05:12:39.653 回答
0

您可以display:inline-block;在每个.formElements块上使用。

见这里:http: //jsfiddle.net/hAwyy/

<div id="container">
    <div class="content">
        <h2 style="text-align:center;">Delete Batch</h2>
        <div class="formElements" style="display:inline-block;">
            <label>Batch code:</label>
            <span><input type="text" id="txtBatchcode" name="txtBatchcode" /></span>
        </div>
        <div class="formElements" style="display:inline-block;">
            <label>Course code:</label>
            <span><input type="text" id="txtCoursecode" name="txtCoursecode" /></span>
        </div>
        <div class="buttons" style="text-align:center;">
            <button type="submit" class="primaryAction">Delete</button>
            <button type="reset" class="primaryAction">Clear</button>
        </div>
    </div>
</div>
于 2013-04-03T05:02:56.753 回答
0

试试这个:定义其中将适用classcss所有.formElements

<style type="text/css">
.formElements{
    display:inline;
}
</style>
于 2013-04-03T05:03:58.300 回答
0

看它很简单,让你的 div 向左浮动 .. 所以它们将从左边开始并以全宽结束,然后它们将发生在下一行。

<div width="100%">
<div style="float:left , width :50%">your content here    </div>
<div style="float:left , width :50%">  your content here </div>
<div></div>,
</div>
于 2013-04-03T05:18:22.643 回答