我需要按钮左右对齐而不是顶部和按钮

时间:2017-02-13 02:18:38

标签: html css



<html>

<body>
  <div align="center">
    <form method="link" action="file:///C:/Users/David/Desktop/about%20samoyeds">
      <input type="submit" value="About Samoyeds" style="width:120px; height:40px; background-color: darkwhite; border-color: black; ">
    </form>
    <form method="link" action="http://www.hillspet.com/en/us/dog-breeds/samoyed">
      <input type="submit" value="History of Samoyeds" style="width:150px; height:40px; background-color: darkwhite; border-color: black; ">
    </form>
    <form method="link" action="file:///C:/Users/David/Desktop/dealers%20of%20samoyeds">
      <input type="submit" value="Samoyed Dealers" style="width:130px; height:40px; background-color: darkwhite; border-color: black; ">
    </form>
  </div>
</body>

</html>
&#13;
&#13;
&#13;

pic of what code comes out as

这是我使用的代码更多但与此无关,所以它不在那里我对该代码有问题

1 个答案:

答案 0 :(得分:3)

制作form元素display: inline-block;

顺便说一句,align属性已弃用。使用CSS来对齐/居中。

.wrap {
  text-align: center;
}
form {
  display: inline-block;
}
<div class="wrap">
    <form method="link" action="file:///C:/Users/David/Desktop/about%20samoyeds">
      <input type="submit" value="About Samoyeds" style="width:120px; height:40px; background-color: darkwhite; border-color: black; ">
    </form>
    <form method="link" action="http://www.hillspet.com/en/us/dog-breeds/samoyed">
      <input type="submit" value="History of Samoyeds" style="width:150px; height:40px; background-color: darkwhite; border-color: black; ">
    </form>
    <form method="link" action="file:///C:/Users/David/Desktop/dealers%20of%20samoyeds">
      <input type="submit" value="Samoyed Dealers" style="width:130px; height:40px; background-color: darkwhite; border-color: black; ">
    </form>
</div>