3

我一直试图让两个下拉列表并排显示,但无法弄清楚。要设置什么 CSS 元素属性来执行此操作。我必须以以下格式显示它:

[company]     [mobile]

代替

[company]

[mobile]

有 3 对这样的对。此外,这对 2 个选择下拉框似乎并不坚持其划分。

<html>
 <head>
   <style>
     body
     {
      background-image:url('gradient1.jpg');
      background-repeat:repeat-x;
     }
     .ex
     {
      margin:auto;
      width:90%;
      padding:10px;
      border:outset;
     }
     select
     {
      display:inline;
      cursor:pointer;
     }
    .ey
     {
      display:inline;
     } 
    .gap
     {
      clear:both;
      margin-bottom:2px;
      }
   </style>
 </head>
 <body>
    <div class="ex">
        <form id='dd1.mob1' name='dd1.mob1' method='post' action=' '>   
            <p><label>Select Company</label></p><br/>
            <select onchange=filter.submit() name='dd1mob1' id='dd1mob1'>
                <option>1</option>
                <option>2</option>" . $options . "
            </select>
        </form>
        <form class="ey" id='dd2.mob1' name='dd2.mob1' method='post' action=''> 
            <p><label>Select Mobile</label></p><br/>
            <select onchange=filter.submit() name='dd2mob1' id='dd2mob1'>
                " . $options . "
            </select>
        </form>
    </div>
    <div class="ex" class="gap" >
        <form  id='dd1.mob2' name='dd1.mob2' method='post' action=' '>  
            <p><label>Select Company</label></p><br/>
            <select onchange=filter.submit() name='dd1mob2' id='dd1mob2'>
                <option>1</option>
                <option>2</option>" . $options . "
            </select>
        </form>
        <form class="ey" id='dd2.mob2' name='dd2.mob2' method='post' action=''> 
            <p><label>Select Mobile</label></p><br/>
            <select onchange=filter.submit() name='dd2mob2' id='dd2mob2'>
                " . $options . "
            </select>
        </form>
    </div>
    <div class="ex" class="gap">
        <form  id='dd1.mob3' name='dd1.mob3' method='post' action=' '>  
            <p><label>Select Company</label></p><br/>
            <select onchange=filter.submit() name='dd1mob3' id='dd1mob3'>
                <option>1</option>
                <option>2</option>" . $options . "
            </select>
        </form>
        <form class="ey" id='dd2.mob3' name='dd2.mob3' method='post' action=''> 
            <p><label>Select Mobile</label></p><br/>
            <select onchange=filter.submit() name='dd2mob3' id='dd2mob3'>
                " . $options . "
            </select>
        </form>
    </div>
 </body>
</html>

4

4 回答 4

6

试试这个 -例子

 body
 {
  background-image:url('gradient1.jpg');
  background-repeat:repeat-x;
 }
 .ex
 {
  margin:auto;
  width:90%;
  padding:10px;
  border:outset;
 }
 select
 {
  display:inline;
  cursor:pointer;
 }
.ey
 {
  display:inline-block;
 } 
form{
    display:inline-block;
}
.gap
 {
  clear:both;
  margin-bottom:2px;
  }
 <body>
<div class="ex">
    <form id='dd1.mob1' name='dd1.mob1' method='post' action=' '>   
        <p><label>Select Company</label></p><br/>
        <select onchange=filter.submit() name='dd1mob1' id='dd1mob1'>
            <option>1</option>
            <option>2</option>" . $options . "
        </select>
    </form>
    <form class="ey" id='dd2.mob1' name='dd2.mob1' method='post' action=''> 
        <p><label>Select Mobile</label></p><br/>
        <select onchange=filter.submit() name='dd2mob1' id='dd2mob1'>
            " . $options . "
        </select>
    </form>
</div>
<div class="ex">
    <form  id='dd1.mob2' name='dd1.mob2' method='post' action=' '>  
        <p><label>Select Company</label></p><br/>
        <select onchange=filter.submit() name='dd1mob2' id='dd1mob2'>
            <option>1</option>
            <option>2</option>" . $options . "
        </select>
    </form>
    <form class="ey" id='dd2.mob2' name='dd2.mob2' method='post' action=''> 
        <p><label>Select Mobile</label></p><br/>
        <select onchange=filter.submit() name='dd2mob2' id='dd2mob2'>
            " . $options . "
        </select>
    </form>
</div>
<div class="ex">
    <form  id='dd1.mob3' name='dd1.mob3' method='post' action=' '>  
        <p><label>Select Company</label></p><br/>
        <select onchange=filter.submit() name='dd1mob3' id='dd1mob3'>
            <option>1</option>
            <option>2</option>" . $options . "
        </select>
    </form>
    <form class="ey" id='dd2.mob3' name='dd2.mob3' method='post' action=''> 
        <p><label>Select Mobile</label></p><br/>
        <select onchange=filter.submit() name='dd2mob3' id='dd2mob3'>
            " . $options . "
        </select>
    </form>
</div>

.ey
 {
  display:inline-block;
 } 
form{
    display:inline-block;
}

请参阅此线程以获得很好的解释display: inline-block;

display: inline 和 display: inline-block 有什么区别?

于 2013-05-07T17:24:27.507 回答
4

这并排显示 2 个下拉列表:

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  </head>
  <body>
    <div style="display:block;">
        <select>
            <option>test1</option>
            <option>test2</option>
        </select>
        <select>
            <option>test1</option>
            <option>test2</option>
       </select>
   </div>
 </body>
</html>
于 2013-05-07T17:08:02.890 回答
0

最快的 CSS 修复是添加类似

form
 {

     float:left;
 }  

但是您可能需要考虑重组,因为单个表单通常不是一个好主意。

然后以同样的方式你可以使用元素来定位。

于 2013-05-07T17:04:57.567 回答
0

使用给定的代码,添加以下 css

.ex, form {
float: left;
}  

label{
    padding: 15px;
}

一个提琴手

也就是说,我仍然建议清理你的代码而不是使用太多的表单。

于 2013-05-07T17:11:40.963 回答