2014-12-06 220 views
-5

我想将提交按钮放在最后一个div上,但我不能这样做。 我尝试了很多东西,比如margin:auto,align-left和right,以及其他人问你在这个页面上做什么,但这对我来说是不可能的。如何居中提交按钮?

<!DOCTYPE html> 
<head> 
    <meta charset="UTF-8"/> 
    <title>Mi Revista</title> 
    <style> 

body { 
    background: #7f7f7f; 
} 

#container { 
    width: 800px; 
    margin: auto; 
    position: relative; 
} 

#header { 
    background: #5783a0; 
    height: 75px; 
} 

#contenido { 
    padding: 1px; 
    background-color: white; 
} 

#left { 
    float:left; 
    width: 470px; 
    background-color: pink; 
    height: 300px; 
} 

#bordei { 
    border-style: solid none; 
    border-width: 2px; 
    border-color: black white; 
    background: #efefef; 
    margin: 0px 0px 2px 10px; 
    font-weight: bold; 
} 

#borded { 
    border-style: solid none; 
    border-width: 2px; 
    border-color: black white; 
    background: #efefef; 
    margin: 0px 10px 2px 0px; 
    font-weight: bold; 
} 

#derecha { 
    float:left; 
    width: 330px; 
    background-color: yellow; 
    height: 300px; 
} 

#footer { 
    height: 50px; 
    background-color: aquamarine; 
    clear:both; 
} 

div form { 
    display:block 
} 

#acept { 
    margin:auto; 
} 


    </style> 
</head> 

<body> 
    <div id="container"> 
     <div id="header"> Mi Revista</div> 
     <div id="contenido"> texto de arriba</div> 
     <div id="left"> 
      <div id="bordei"> borde uno</div> 
      formulario izquierda 
     </div> 
     <div id="derecha"> 
      <div id="borded">borde derecha </div> 
      Formulario derecha 
      </div> 
     <div id="footer"> 
      <form id="acept"> 
       <input type="submit" name="submit" value="Aceptar"/> 
      </form> 
      </div> 
    </div> 
</body> 
</html> 

我等待你的赞美,因为我不能做任何形式的。 Thaks

+1

[对齐按钮到中心]的可能重复(http://stackoverflow.com/questions/9971740/aligning-a-按钮到中心) – Sparky 2014-12-06 18:12:17

回答

1

使用#acept中的text-align:center是最简单的方法。 您不妨使用& ltcenter & gt标签,但不推荐使用。所以最好的办法是改变

#acept{ 
margin:auto; 
} 

#acept{ 
margin:auto; 
text-align:center; 
} 
2

更改CSS略如下

#acept { 
    width:20px; 
    margin:0 auto; 
} 

的问题是,你wasnt指定宽度的形式和原因在于它采取100%width.And因此margin:0 auto不起作用。

我已经做了fiddle。请检查一下..

2

只要给对准中心页脚DIV

​​
+0

这是一个比在css中明确指定宽度更好的解决方案。 +1 – Aditya 2014-12-06 18:03:49