如何使用 html/css 在网站上定位按钮

新手上路,请多包涵

编辑:背景只是一张图片,我放置图片的部分就是我给出的

我的网页目前看起来像这样,我已经指出了我想要按钮的位置,但是我对一般的编码还很陌生,不知道如何实现这一点。

网站页面图片: 这里

这是我的html代码,非常简单只需要添加按钮

<section class="slide kenBurns">
  <div class="content">
    <div class="container">
      <div><p class="ae-2">

          </p></div>
      <div class="wrap">
        <div class="fix-7-12">
          <!-- <h1 class="ae-1">Messes Make Memories</h1> -->

        </div>
      </div>
    </div>
  </div>
  <img
    src="assets/img/background/flood2.png"
    width="1450"
    height="850"
  ></img>
</section>

原文由 CS-learner 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 553
2 个回答

好吧,试试这个代码

    <!DOCTYPE html>
   <html>
     <head>
       <style>

       .img {
       width:100%;
       height: auto;
       top:0;
       left:0;
       position: relative;
       z-index: 1;
       }

       .anybutton {
       top:11%;
       left:55%;
       width:100px;
       height:40px;
       position: absolute;
       z-index: 2;
       background: orange;
       }

      </style>
   </head>

     <body style="text-align:center; margin: 0px;">

       <div class="mycenter" id="">
          <img src="assets/img/background/flood2.png" class="img" id="img" />
          <input type="button" class="anybutton" id="myab" value="Right Here" />
       </div>

      </body>
</html>

原文由 Anonymouse Lovecat 发布,翻译遵循 CC BY-SA 4.0 许可协议

有两种类型的按钮 真正的按钮。它用于为 JavaScript 触发事件。它的工作方式如下例所示,并且可以像下面这样设置样式。您可以将其插入任何您想要的位置。

 button {
  background-color: blue;
  width: 200px;
  font-size: 20px;
  padding: 10px;
  border-radius: 5px;
  border: 3px solid yellow;
  color: white;
  cursor: pointer;
}
 <button id="ID">I'm a Button</button>

然后是伪按钮。它不是一个真正的按钮。它只是一个 div 框,可以像按钮一样设置链接样式:

 .button {
  background-color: blue;
  width: 200px;
  font-size: 20px;
  padding: 10px;
  border-radius: 5px;
  border: 3px solid yellow;
  color: white;
  text-align: center;
}
 <a href=""><div class="button">I'm a Button</div></a>

原文由 tacoshy 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏