Click here to Skip to main content
15,887,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends

How to align the div element to different size ? Ex: I want to display Image,login details,some content all in single row,guide me how to align the div ? in css what should I use either % or px or em ?



Thanks
Posted
Comments
vangapally Naveen Kumar 28-Aug-14 3:18am    
please elaborate more..........
vikyas26 28-Aug-14 4:34am    
I am using <div> tags in my project, this is new to me because I used <table> only before so by using <div> I want to know how to divide the <div> to particular size I used width=100% also but still its not coming correctly,give me the solution.
ChintanShukla 28-Aug-14 4:16am    
Use table instead of div even if you are keen to use div use position and width attribute in css also make sure that all the content sum up to 100%

1 solution

Is this what you are thinking?

Note divs one, two, three need to be right after each other otherwise you will get a funny spacing(div three will drop to a new row).

HTML
<div style="width:480px; border:1px solid purple; ">
    <div style="width:40%; display:inline-block;">First</div><div style="width:20%; display:inline-block;">Second</div><div style="width:40%; display:inline-block;">Third</div>
</div>
 
Share this answer
 
v2
Comments
vikyas26 29-Aug-14 12:46pm    
yes, I got your answer jared,is <div> is best way to design or <table> is best way for respondive designs ? let me know shall I use Bootstrap method or shall I write my own responsive css code ?
SteveyJDay 29-Aug-14 13:57pm    
<div> are preferred for responsive design. <table> are for displaying tabular data such as football standings or the results of a race. Not for laying out a website.

Using Bootstrap is up to you. You can accomplish the same look and feel with or without bootstrap. CSS Media queries are the driving force between responsive design. The Bootstrap developers have complied these media queries.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900