Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to align div's side by side in the center of web page

Posted on 2010-08-13
7
Medium Priority
?
1,003 Views
Last Modified: 2012-05-10
how do i align the 3 divs in the center of the page?

thanks


<html>
<head>
      <title>Untitled</title>
   
      <style type="text/css">
            #h1   {width:200px; text-align:center; float:left}
            #h2   {width:200px; text-align:center; float:left}
            #h3   {width:200px; text-align:center; float:left}
      </style>

</head>

<body>

		<div align="center" style="background-color: #E7EFEF">
		<div id="h1">hello 1<br>
		</div>
		<div id="h2">hello 2<br>
		</div>
		<div id="h3">hello 3</div>
		
		<br>

		</div>
</body>
</html>

Open in new window

0
Comment
Question by:webdott
  • 3
  • 3
7 Comments
 
LVL 18

Expert Comment

by:Anil Golamari
ID: 33433183
div#container
{
      margin-left: auto;
      margin-right: auto;
      
}
0
 
LVL 18

Expert Comment

by:Anil Golamari
ID: 33433246
<style type="text/css">
            #h1   {width:200px; text-align:center;  margin-left:auto; margin-right:auto }
            #h2   {width:200px; text-align:center;  margin-left:auto; margin-right:auto}
            #h3   {width:200px; text-align:center;  margin-left:auto; margin-right:auto}
      </style>

Try this.
0
 

Author Comment

by:webdott
ID: 33433335
i tried this;



      Untitled
   
     





            
            hello 1

            
            hello 2

            
            hello 3
            
            


            



it aligned in the center, but it aligned them on top of each other rather than side-by-side
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:webdott
ID: 33433409
sorry - that did not include the divs
<html>
<head>
      <title>Untitled</title>
   
      <style type="text/css">
      		#container	 {margin-left:auto; margin-right:auto }
            #h1   		 {width:200px; text-align:center; margin-left:auto; margin-right:auto }
            #h2  		 {width:200px; text-align:center; margin-left:auto; margin-right:auto }
            #h3  		 {width:200px; text-align:center; margin-left:auto; margin-right:auto }
      </style>

</head>

<body>

		<div style="background-color: #E7EFEF" id="container">
		<div id="h1">hello 1<br>
		</div>
		<div id="h2">hello 2<br>
		</div>
		<div id="h3">hello 3</div>
		
		<br>

		</div>
</body>
</html>

Open in new window

0
 
LVL 18

Expert Comment

by:Anil Golamari
ID: 33433460
<html>
<head>
    <title>Untitled</title>
    <style type="text/css">        
        #LeftBox
        {
            float: left;
            width: 300px;
        }
        #RightBox
        {          
           
            margin: -5px 0 0 0; /* positions the box next to the other. This will have to be adjusted depending on the LeftBox.*/
        }
        #ThirdBox
        {
              float: right;
           
            margin: -40px 0 0 0;
        }
    </style>
</head>
<body>
    <div id="LeftBox">
        <p>
             hello 1</p>
    </div>
    <div id="RighBox">
        <p>
             hello 2</p>
    </div>
    <div id="ThirdBox">
    <p>
           hello 3</p>
    </div>    
</body>
</html>

This should fix it.
0
 
LVL 16

Accepted Solution

by:
HagayMandel earned 2000 total points
ID: 33436669
If by center of the page you men horizontally centered, then this is it:
<html>
<head>
<title>Untitled</title>
<style type="text/css">
#h1   {width:200px; text-align:center; display: inline;}
#h2   {width:200px; text-align:center; display: inline;}
#h3   {width:200px; text-align:center; display: inline;}
#wrapper {clear: both; margin-right: auto; margin-left: auto; width: 100%;}
</style>
</head>
<body>
      <div align="center" id="wrapper">
      <div id="h1">hello 1</div>
      <div id="h2">hello 2</div>
      <div id="h3">hello 3</div>
      </div>
</body>
</html>
0
 

Author Closing Comment

by:webdott
ID: 33451107
thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question