2016-09-25 4 views
-3

div1の中にdiv2を作成する必要があります。ここでの問題は、私はそれらの2つのdivを並べて作る必要があるということです。私はfloatを適用しようとしましたが、マージンは残っていましたが、それでも私はそれを実現できません。別のDiv1のDiv2。これらのDiv1とDiv2を並べて表示させる方法

コードがそう

<div1> <form> <div2>here I have to write div2</div2></form><div1> 

ようになり、DIV1とDIV2が並んで表示されていることを任意の可能性があります。

ありがとうございました。

+0

あなたは絶対位置を使用する必要があります。 –

+0

どのように表示されるべきかを示す画像を投稿してください – LGSon

答えて

1

div2の左余白をdiv1の幅より大きくしてくれました。

<!DOCTYPE html> 
 
<html> 
 
<head> 
 
\t <title></title> 
 
\t <style type="text/css"> 
 
    #one{ 
 
    \t height: 100px; 
 
    \t width:200px; 
 
    \t border:1px solid black; 
 
    \t background-color: blue; 
 
    \t 
 
     
 
    } 
 
    #two{ 
 
    \t height: 100px; 
 
    \t width:200px; 
 
    \t border:1px solid black; 
 
    \t margin-left:230px; 
 
     background-color:yellow; 
 
    } 
 
\t </style> 
 
</head> 
 
<body> 
 
<div id="one"> 
 
<form> 
 
<div id="two"> 
 
here I have to write div2 
 
</div> 
 
</form> 
 
</div> 
 
</body> 
 
</html>

enter image description here

-1

ここでは、あなたの質問によると、あなたの答えです。

div1 { 
 
    display: inline-flex; 
 
    border: 1px solid red; 
 
} 
 

 
div2 { 
 
    padding-left: 10px; 
 
    border: 1px solid blue; 
 
}
<div1> 
 
test 
 
<form> 
 
<div2>here I have to write div2</div2> 
 
</form> 
 
    <div1>

関連する問題