简体   繁体   English

另一个 Div1 内的 Div2。 如何让这些 Div1 和 Div2 并排出现

[英]Div2 inside another Div1. How to make these Div1 and Div2 to be appeared side by side

I have to create div2 inside div1.我必须在 div1 中创建 div2。 The problem here is I have to make those two div's side by side.这里的问题是我必须将这两个 div 并排放置。 I tried to apply float, margin-left but still I can't make it happen.我尝试应用浮动,左边距,但仍然无法实现。

Code will be like代码会像

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

So, is there any chance that div1 and div2 appear side by side.那么,div1 和 div2 是否有可能并排出现。

Thanks.谢谢。

I just made the left margin of div2 greater than the width of div1 and it worked for me.我只是让 div2 的左边距大于 div1 的宽度,它对我有用。

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

在此处输入图片说明

According to your question Here is your answer.根据您的问题,这是您的答案。

 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM