简体   繁体   中英

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

I have to create div2 inside div1. The problem here is I have to make those two div's side by side. 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.

Thanks.

I just made the left margin of div2 greater than the width of div1 and it worked for me.

 <!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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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