Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

A button gets out of the div

I have the following navbar –

#navbar {
  width: 100%;
  position: fixed;
  height: 50px;
  z-index: 1 !important;
  top: 0px;
  background-color: #20b7c2;
}

#Name {
  padding: 0px !important;
  top: 0px;
}

.openbtn {
  background-color: #20b7c2;
  height: 50px;
  cursor: pointer;
  margin-right: 0px;
  border: 1px white solid;
  border-radius: 0px;
  width: 50px !important;
  padding: 0px;
  font-size: 25px;
}

.navbarButtons1 {
  background-color: #20b7c2;
  color: white;
  border: 0px;
  cursor: Default;
  vertical-align: middle;
  height: 50px;
  top: 0;
  width: 100px;
  position: relative;
  font-size: 15px;
}
<div id="navbar">
  <button class="openbtn" onclick="openNav()">&#9776;</button>
  <input class="navbarButtons1" type="button" value="Test" id="Name">
</div>

In it, the second button with the value "test" just overflows out of the div for no reason at all. I tried some things but they did not work. How to fix it? Thanks in advance.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Just add float: left to each button.

#navbar {
  width: 100%;
  position: fixed;
  height: 50px;
  z-index: 1 !important;
  top: 0px;
  background-color: #20b7c2;
}

#Name {
  padding: 0px !important;
  top: 0px;
  float: left;
}

.openbtn {
  background-color: #20b7c2;
  height: 50px;
  cursor: pointer;
  margin-right: 0px;
  border: 1px white solid;
  border-radius: 0px;
  width: 50px !important;
  padding: 0px;
  font-size: 25px;
  float: left;
}

.navbarButtons1 {
  background-color: #20b7c2;
  color: white;
  border: 0px;
  cursor: Default;
  vertical-align: middle;
  height: 50px;
  top: 0;
  width: 100px;
  position: relative;
  font-size: 15px;
}
<div id="navbar">
  <button class="openbtn" onclick="openNav()">&#9776;</button>
  <input class="navbarButtons1" type="button" value="Test" id="Name">
</div>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading