horizontally align div

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • colinod
    Contributor
    • Nov 2007
    • 347

    horizontally align div

    I have a page that has rows and columns of divs within a main div and am trying to align them to centre if the divs do not fill the line

    example here

    Yakety Yak is a leading Voice Over Agency based in London. We specialise in Voice Casting, Celebrity Voiceovers as well as English and International voices.


    the main div css is as follows
    Code:
    #artists {
    	float: left;
    	height: 615px;
    	width: 840px;
    	overflow:auto;
    	overflow-x:hidden;
    	overflow-y: auto;
    	top: 180px;
    	/* [disabled]background-color: #FFF; */
    	padding: 5px;
    }
    and the internal div for each element is this

    Code:
    .artistboys  {
    	/*border: 1px solid #f39617;*/
    	width: 85px;
    	height: 130px;
    	margin-top: 7px;
    	margin-right: 7px;
    	margin-bottom: 7px;
    	margin-left: 7px;
    	padding-top: 10px;
    	text-align: center;
    }
    i have tried everything i know but all i can get is a long list of single elemnts under one another??

    any help would be appreciated
  • Murat Bastas
    New Member
    • Jul 2012
    • 25

    #2
    if you set your div's margin-left:auto and margin-right:auto, would want to...

    Example :
    Code:
    <div style="width:100%; background:green;"><!-- or your width -->
        <div style="width:400px; margin:0 auto; background:red; color: white;">example grid</div>
    </div>

    Comment

    • colinod
      Contributor
      • Nov 2007
      • 347

      #3
      so would i put the divs that make up my grid in where you have put example grid

      thanks

      Comment

      • colinod
        Contributor
        • Nov 2007
        • 347

        #4
        that centres the conatining div but not the items in the grid

        Comment

        Working...