2017-04-27 116 views
-1

真的很愚蠢的问题,但它奇怪。 我想分开2个div,一个向左,一个向右。 我试图使用CSS属性“浮动”,但没有任何反应。角度与CSS

编辑: HTML

<h4>Profile</h4> 
      <div class="form-group"> 
       <div class="input-group"> 
        <div class="text-form">Full Name</div> 
        <div class="inner"> 
         <input type="text" class="account-box" ng-model="name"> 
        </div> 
       </div> 
      </div> 
      <div class="form-group"> 
       <div class="input-group"> 
        <div class="text-form">Company Name</div> 
        <div class="inner"> 
         <input type="text" class="account-box" ng-model="companyName"> 
        </div> 
       </div> 
      </div> 

CSS:

.container { 
    position: static; 
    width: 500px; 
    height: 500px; 
    text-align: left; 
} 

.inner { 
    display:inline-block; 
    position:static; 
    top:2px; 
    padding-right:10px; 
    clear: both; 
} 

谢谢!

+1

分享你的CSS以及 –

+0

请[学会爱标签(HTTP://www.456bereastreet。 com/archive/200711/use_the_label_element_to_make_your_html_forms_accessible /) – Quentin

+0

你的截图和HTML显示完全不同的东西。提供一个真实的[mcve] – Quentin

回答

1

希望能够帮助您

<div class="input-group" style="width: 300px;display: flex;justify-content: space-between;"> 
    <div class="text-form">Full Name</div> 
    <div class="inner"> 
     <input type="text" class="account-box" ng-model="name"> 
    </div> 
</div> 
+0

。谢谢!你能解释我为什么吗?下次 –

+0

显示:flex表示灵活的布局,证明内容定义子元素的对齐 –

1

这是我的一个div,其中一个坐在左边,一个坐在右边,通过浮动和边距以适应他们。并且不要忘记清楚:两个都在最后,所以不会出现任何问题之后来。希望这有助于:)

<div style="border-style:none"> 
    <table id="table_user" style="border-style:ridge;width: 22%;float: left; margin-top:20px; margin-left:10px;"> 
     <thead> 
      <tr> 
       <th style= 'width:10%'>Benutzer</th> 
       <th style= 'width:10%'>Check </th> 
      </tr> 
     </thead> 
    </table> 
</div> 
<div style="border-style:none"> 
    <table id="table_benutzergruppe" style="border-style:ridge;width: 25%;float: left;margin-left: 25px; margin-top:20px;"> 
     <thead> 
      <tr> 
       <th style= 'width:10%'>Benutzergruppe</th> 
       <th style= 'width:10%'>Check </th> 
      </tr> 
     </thead> 
    </table> 
</div> 
<div style="clear: both;"></div>  
8
<div class="container"> 
    <h4>Password Change</h4> 
    <div class="form-group"> 
     <div class="input-group"> 
      <div class="text-form" id="left">Password <span style="color:red;">*</span> 
      <input type="password" placeholder="required" class="account-box" required="" ng-model="password"> 
      </div> 
     </div> 
    </div> 
</div>