-7
#container {
width: 960px;
margin-left: auto;
margin-right: auto;
height: auto; }

#large_box {
text-align: center;
width: 960px;
margin-left: auto;
margin-right: auto;
height: auto; }

#searchbcid {
position: absolute;
left: 400px;
margin-left: 50px;
top: 280px; }

#createbcid {
position: absolute;
margin-left: 250px;
top: 280px;
left: 550px; }

#loginpos {
position: absolute;
margin-left: 20px;
left: 30px;
top: 280px; }

in my html there is a div named container. All the other divs are placed in within the container. Another div ie, large_box which contains 3 other div's such as loginpos,searchbcid,createbcid.

But i can't center align the div large_box.

How can I center align it?

Tintumon M
  • 1,156
  • 2
  • 14
  • 36

5 Answers5

0

In your css use only margin:0 auto; with some width for div then it will automatically aligned in center of that provided width.

happy coding...

0

CSS:

#wrapper_div{
width:500px;
height:500px;
}

#inner_div{
width:200px;
margin:0 auto;
}

HTML:

<div id="wrapper_div">
<div id="inner_div">
Centred content here!
</div>
</div
JDavies
  • 2,730
  • 7
  • 34
  • 54
0

This works for me.

CSS

div#center{
      width:250px;
      margin:0 auto;
      background-color:yellow;
}

/* To support IE */
div#parent{
      align:center;
}

HTML

    <div id="parent">    
      <div id="center">
        I'm in the middle!
      </div>
    </div>

JSFiddle Link

0

Try setting your margin to 0 auto, it will horizontally center your element within its container with your specified width.

#large_box {
text-align: center;
width: 960px;
margin: 0 auto;
height: auto; }
tismle
  • 101
  • 1
  • 2
0

Use this css for the div. It will horizontally center.

#large_box {
  width: 960px;
  margin: 0 auto; 
}
Gayashan Perera
  • 661
  • 7
  • 12