how to put a button on top between two dives?

杀马特。学长 韩版系。学妹 提交于 2019-12-13 08:01:14

问题


I want to make a design like this using css, but i don't know how to put this button on top between two divs, can anyone help me?

<div></div>
button
<div></div>

回答1:


You can also use negative margin-top to pull your element up.




回答2:


Make the button style position: absolute; and define the right and top or bottom properties.

If you want the button to be fixed while scrolling, set position: fixed;

#up{
background-color:#B7005D;
height:10vh;
width:100%;
}
#middle{
background-color:#E0E1E0;
height:40vh;
width:100%;
}
#floating-button{
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #B7005D;
  position: fixed;
  top: calc(50% - 25px);
  right: 30px;
  cursor: pointer;
  box-shadow: 0px 2px 5px #666;
}
<div id="up"></div>
<div id="middle"></div>
<div id="floating-button"></div>


来源:https://stackoverflow.com/questions/44870666/how-to-put-a-button-on-top-between-two-dives

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!