Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to show 2 or more DIVs side by side without using float: left/right?

I have a requirement to show2-3 DIVs side by side. For this purpose I usually use float:left but now there is a requirement for not using float.

user-image
Question added by Muhammad Zaid , Senior Front End Developer , Royaltri Inc.
Date Posted: 2017/03/28
Khaled Mahmoud
by Khaled Mahmoud , مسؤول نظم معلومات , unicare

with flexbox property

Talal Tahir Malik
by Talal Tahir Malik , Software Engineer , Halalah Company

You can use flexbox

display:flex;

or as others have mentioned

display:inline-block;

Ouali Rahli
by Ouali Rahli , Développeur Front-End , Nearbee

div {

display:inline-block;

}

Nagurbee Shaik
by Nagurbee Shaik , Software Engineer , Saru Soft Technologies PVT LTD

use this attribute display:inline

Alaa Tabash
by Alaa Tabash , مبرمج صفحات الكترونية وتطبيقات الانترنت , وزارة الإتصالات وتكنولوجيا المعلومات

OCTYPE html>

<html>

<head>

<title></title>  

<style type="text/css"> 

   .di{ 

 display: inline-block; 

 width: 200px; 

 height: 200px; 

 border: 2px;

 background: red;

 

      }

 

</style>

</head>

<body>   

<!-- <input type="text" id="myInput" oninput="myFunction()"> -->

 

 

<!-- <button id="button"> show </button>  -->

<!-- <iframe src="https://www.w3schools.com" id="load" width="100%" height="590"></iframe> -->

<input type="text" id="in" onchange=" myname()" > 

<!-- <button  onclick="click() ">  </button> -->

  <p id="demo"></p>

<!-- <input type="text" id="demo" value=" 5"> -->  

<div class="di">

alaa tabash

</div>

<div class="di">

alaa tabash

</div>

<div class="di">

alaa tabash

</div>

<div class="di">

alaa tabash

</div>

<script type="text/javascript" src="alaa.js"> </script> 

 

</body>

</html>

Deleted user
by Deleted user

I normally use display:flex; for this purpose but that's the whole another level. Check out this 

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

Shabaz khan
by Shabaz khan , Senior Project Engineer , Wipro Technologies Ltd

by using display: inline-block 

Ashraf CA
by Ashraf CA , DIGITAL MARKETING & MULTIMEDIA DESIGNER , Standard Marconi DMCC

The usual method when not using floats is to use display: inline-block: 

More Questions Like This