简体   繁体   中英

how to dispaly div element side by side

div element is block element and default display property is block , to display it in line , inline-block property can be used.

 <!DOCTYPE html> <html> <head> <title>Pictures</title> <style type="text/css"> .row { height: 50px; width: 50px; } .row1 { padding-bottom: 12px; display: inline-block; float: left; padding-right: 14px; } .row2 { display: inline-block; } } #img1 { max-width: 50%; max-height: 20%; } </style> <script type="text/javascript"> </script> </head> <body> <div class="content"> <div class="row"> <div class="row1"> <!--img height="50px" width="50px" src="images/image1.jpg"--> hello </div> <div class="row2"> Beutiful picture clicked by photographer </div> </div> </div> </body> </html>

I don't understand why these 2 divs are not getting display side by side , i am using inline-block but still no help.

这很容易..因为您要应用属性“ width”。

It is because the .row has width so less such that it can't accomodate both div. Try this it will make both parallel.

.row {
  height: 50px;
  width: 1000px;
}

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