-1

I tried to align the center of these elements in the contact page.

http://avocat.dac-proiect.ro/wp/?page_id=19

.contactform11 .wdform_section.{
    /* margin-left:280px; */
    /* margin-top:55px; */
    margin:0 auto;
    display:block;
    width:auto;       
 } 

Do not operate this and do not understand why. I searched the forum and everyone said the information you need to set width and display block.

Can you help me to solve this problem?

Thanks in advance!

stanze
  • 2,456
  • 10
  • 13
Diaconescu
  • 41
  • 5
  • Try setting a fixed width instead of width:auto. Similar to this question: http://stackoverflow.com/questions/963636/why-cant-i-center-with-margin-0-auto – Candlejack Mar 20 '15 at 09:52
  • set width in %, Its working fine for me.. .contactform11 .wdform_page { background: none repeat scroll 0 0 transparent; border-radius: 0; font-family: Segoe UI; margin: 0 auto; width: 80%; } – G.L.P Mar 20 '15 at 09:52
  • The width of a block element is 100%. You'll need to set a width lesser than the parent width for an element to center. – ᴍᴀᴛᴛ ʙᴀᴋᴇʀ Mar 20 '15 at 09:53
  • Please post the relevant HTML within your question, otherwise this question will be completely worthless once that page you've linked to has been edited. – James Donnelly Mar 20 '15 at 09:53
  • You forgot the comma in between the two divs: .contactform11, .wdform_section. { – Mugé Mar 20 '15 at 09:55

3 Answers3

2

Width must be constant for margin to be auto.

sainiankit
  • 571
  • 3
  • 17
0

Block elements have a default width of 100%, so auto margin doesn't make sense.

You can either make it an inline-block element (with a text-align set to center on the parent element), or simply define a specific width.

body {text-align: center;}
div {
  background: #ccf;
  margin: 4px auto;
  padding: 4px;
  border: 2px solid #99f;
}

#d2 {display: inline-block;}
#d3 {width: 200px;}
<div id="d1">Original</div>
<div id="d2">Inline-block</div>
<div id="d3">Specific Width</div>
Shomz
  • 37,421
  • 4
  • 57
  • 85
0

in your contact page edit css as

.wdform_page {
  text-align: center;
}
.wdform_section {
  text-align: left;
  margin: auto 0;
}
JitHiN N JOsE
  • 509
  • 4
  • 11