Deano Deano - 12 days ago 4
CSS Question

How to bring a button on top of other elements

I have issue with boostrap button, I would like the button to appear on top of the hr line and a padding similar to "mounted drives" text on the right.

enter image description here

What is the appropriate way to solve this issue? I have tried using Z-index yet, the image remains under the line.

I have tried to use but it didn't work

z-index: 10 !important;


Here is my html code for your reference.

http://jsfiddle.net/8ktzhjw3/

Answer

z-index works only on position relative, fixed, absolute. An element is mandatory to have that for the z-index to work. A solution would be to add position: relative; to your button, #BUTTON_4:

#DIV_1 {
  background-color: #212121;
  bottom: 0px;
  box-sizing: border-box;
  color: rgb(92, 92, 92);
  height: 38px;
  left: 0px;
  position: relative;
  right: 0px;
  text-align: left;
  text-size-adjust: 100%;
  text-transform: uppercase;
  top: 0px;
  width: 750px;
  column-rule-color: rgb(92, 92, 92);
  perspective-origin: 375px 19px;
  transform-origin: 375px 19px;
  border: 0px none rgb(92, 92, 92);
  font: normal normal normal normal 12px / 20px -apple-system, "Helvetica Neue", Helvetica, "Segoe UI", Arial, sans-serif;
  margin: 30px 0px 10px;
  outline: rgb(92, 92, 92) none 0px;
}
/*#DIV_1*/

#DIV_1:before {
  bottom: 18px;
  box-sizing: border-box;
  color: rgb(92, 92, 92);
  content: '""';
  display: block;
  height: 1px;
  left: 0px;
  position: absolute;
  right: 0px;
  text-align: left;
  text-size-adjust: 100%;
  text-transform: uppercase;
  top: 19px;
  width: 750px;
  column-rule-color: rgb(92, 92, 92);
  perspective-origin: 375px 0.5px;
  transform-origin: 375px 0.5px;
  background: rgb(56, 56, 56) none repeat scroll 0% 0% / auto padding-box border-box;
  border: 0px none rgb(92, 92, 92);
  font: normal normal normal normal 12px / 20px -apple-system, "Helvetica Neue", Helvetica, "Segoe UI", Arial, sans-serif;
  outline: rgb(92, 92, 92) none 0px;
}
/*#DIV_1:before*/

#H6_2 {
  bottom: 0px;
  box-sizing: border-box;
  color: rgb(92, 92, 92);
  display: inline-block;
  height: 19px;
  left: 0px;
  position: relative;
  right: 0px;
  text-align: left;
  text-size-adjust: 100%;
  text-transform: uppercase;
  top: 0px;
  vertical-align: middle;
  width: 121.562px;
  z-index: 2;
  column-rule-color: rgb(92, 92, 92);
  perspective-origin: 60.7812px 9.5px;
  transform-origin: 60.7812px 9.5px;
  background: rgb(33, 33, 33) none repeat scroll 0% 0% / auto padding-box border-box;
  border: 0px none rgb(92, 92, 92);
  font: normal normal 500 normal 12px / 19.2px -apple-system, "Helvetica Neue", Helvetica, "Segoe UI", Arial, sans-serif;
  margin: 9.5px 0px;
  outline: rgb(92, 92, 92) none 0px;
  padding: 0px 12px 0px 0px;
}
/*#H6_2*/

#STRONG_3 {
  box-sizing: border-box;
  color: rgb(92, 92, 92);
  text-align: left;
  text-size-adjust: 100%;
  text-transform: uppercase;
  column-rule-color: rgb(92, 92, 92);
  border: 0px none rgb(92, 92, 92);
  font: normal normal bold normal 12px / 19.2px -apple-system, "Helvetica Neue", Helvetica, "Segoe UI", Arial, sans-serif;
  outline: rgb(92, 92, 92) none 0px;
}
/*#STRONG_3*/

#BUTTON_4 {
  color: rgb(255, 255, 255);
  cursor: pointer;
  display: block;
  float: right;
  height: 33px;
  min-height: 0px;
  text-size-adjust: 100%;
  touch-action: manipulation;
  vertical-align: middle;
  white-space: nowrap;
  width: 98.2656px;
  z-index: 0;
  column-rule-color: rgb(255, 255, 255);
  perspective-origin: 49.125px 16.5px;
  transform-origin: 49.125px 16.5px;
  user-select: none;
  background: rgb(44, 151, 222) none repeat scroll 0% 0% / auto padding-box border-box;
  border: 1px solid rgb(33, 138, 208);
  border-radius: 2px 2px 2px 2px;
  font: normal normal normal normal 13px / 19.8714px -apple-system, "Helvetica Neue", Helvetica, "Segoe UI", Arial, sans-serif;
  outline: rgb(255, 255, 255) none 0px;
  padding: 6px 12px;
  position: relative;
}
/*#BUTTON_4*/
<div id="DIV_1">
  <h6 id="H6_2">
	 <strong id="STRONG_3">Mounted Drives</strong>
  </h6>
  <button type="button" id="BUTTON_4">
    Add Domain
  </button>
</div>