2017-11-18 21 views
-3

私は主要素(テキスト入力)の右側に配置したい要素(スパン)を持っています。主要素は親divの中央に配置されます。私はスパンの相対的な位置を設定する場合は、親の真ん中から入力を移動し、入力の左側で開始します。左にあり、動かずに)スクロールで入力サイズが変化しているので、親に対して相対的な位置を設定したくありません。 ところで、私のウェブ全体が方向性を持っています:rtl、もし私がそれを変更すれば、入力の右側にスパンがありますが、それもセンターから移動します。そして、私の他の要素の方向を変更したくありません。ウェブ。 thenks :)他の要素と相対的に要素を配置する

+2

が解決[最小、完全な検証可能例(https://stackoverflow.com/help/mcve) – bhansa

答えて

0

body{ 
 
    direction: rtl; 
 
} 
 
.main_div{ 
 
    background: red; 
 
    margin: auto; 
 
    padding: 10px; 
 
    text-align: center; 
 
    width:400px; 
 
    height: 600px; 
 
} 
 
input{ \t 
 
    margin: 30px auto; 
 
} 
 
span.titles{ 
 
    display:block; 
 
}
<html> 
 
    <head> 
 
    </head> 
 
    <body> 
 
    <div class="main_div"> 
 
     <form> 
 
     <span class="titles">input 1</span><span>the additional span</span><input type="text"> 
 
     <span class="titles">input 2</span><input type="text"> 
 
     <p>i want input 1 to be in the center and the additional span to go more left and i want it to be dynamic like always 5px space to the right of the input. 
 
     thenks 
 
    </div> 
 
    </body> 
 
    </html>

+0

を作成してください。私はテーブルを使いました。 –