2017-08-04 89 views
0

我尝试将我的下拉列表与左侧的textarea垂直对齐。我不知道它为什么会在一起发生冲突。如何在左右两边垂直对齐两个div?

编辑:感谢您的帮助,我做出了改变,实现它。

JSP:

.ExeDropdown{ 
 
    \t float:left; 
 
    margin-left:50px; 
 
} 
 
div.txt1{ 
 
    float: left; 
 
    margin-left:50px; 
 
} 
 
div.txt2{ 
 
    float:right; 
 
    margin-right: 120px; 
 
} 
 
.txt3{ 
 
    \t float:right; 
 
\t margin-right: 120px; 
 
} 
 
#subBtn{ 
 
    \t position: absolute; 
 
    bottom: 20%; 
 
    left:47%; 
 
}
<div class="ExeDropdown"> 
 
    Select an exercise: 
 
    <select name="ProgExe"> 
 
     <option value="exe1">Exercise 1</option> 
 
     <option value="exe2">Exercise 2</option> 
 
    </select> 
 
</div>  
 
<div class="txt1" > 
 
    <p>Write your source code here:</p> 
 
    <textarea id="myTextArea" rows="5" cols="40" name="txtInput" > 
 
    </textarea> 
 
</div>

https://i.stack.imgur.com/Vok8d.jpg

+0

你能更具体? –

+0

我想我的div.exedropdown高于我的div.txt1左对齐 –

+0

蒂姆,它的工作? –

回答

0

在这里你去:

HTML:

<div class="ExeDropdown"> 
Select an exercise: 
<select name="ProgExe"> 
    <option value="exe1">Exercise 1</option> 
    <option value="exe2">Exercise 2</option> 
</select> 
</div>  
<div class="clear"></div> 
<div class="txt1" > 
<p>Write your source code here:</p> 
<textarea id="myTextArea" rows="5" cols="40" name="txtInput" > 
</textarea> 
</div> 

CSS:

.clear{clear:both;} 
-1

添加(线 - )之前它突破:

Select an exercise: 
<br /> <!-- here --> 
<select name="ProgExe"> 
0

取出两个元素的float:left;你提到(.ExeD ropdown,div.txt1)。

它应该工作,然后