首页 > 解决方案 > 防止 div 内的图标折叠到其他 div 内

问题描述

因此,使用 HTML、CSS 和 Bootstrap,我在包装器的左侧有 4 个图标,它们的组织类似于正方形。但是当我调整窗口大小时,这些图标会在我下面的控制台后面折叠。我怎样才能防止这种情况发生(将按钮保持在同一位置会很好)?

普通窗口,带有方形按钮

调整大小后

这是 CSS 和 HTML 的代码

#designContainer {
  display: none;
  background-color: #fff;
  position: absolute;
  bottom: 40px;
  top: 120px;
  left: 10%;
  /*width of toolbar*/
  margin-left: 38px;
  /*margin of toolbar*/
  right: 20px;
  overflow: hidden;
  border: 1px solid #003399;
  /* border-top:3px solid #FFCC00; */
  z-index: 10;
  cursor: crosshair;
}

#toolsWrapper {
  display: none;
  background-color: #fff;
  position: absolute;
  bottom: 40px;
  top: 120px;
  left: 20px;
  width: 10%;
  overflow: hidden;
  z-index: 11;
  margin-bottom: 0;
}

#toolsWrapper label img {
  position: relative;
  width: 30px;
  height: auto;
  margin: 10px 0px;
  opacity: 0.3;
  transition: 0.2s;
}

#toolsWrapper [type=radio] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}


/* IMAGE STYLES */

#toolsWrapper [type=radio]+img {
  cursor: pointer;
}


/* CHECKED STYLES */

#toolsWrapper [type=radio]:checked+img {
  opacity: 1;
}

#toolsWrapper [type=radio]:checked+img:hover {
  opacity: 1;
}

#toolsWrapper [type=radio]+img:hover {
  opacity: 0.7;
}

#sideToolButtons {
  margin-bottom: 20px;
}

#sideToolButtons button {
  outline: none;
  width: 20px;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

#sideToolButtons button:hover>img {
  opacity: 1;
}

#sideToolButtons button>img {
  width: 100%;
  height: 100%;
  opacity: 0.7;
}

#sideToolButtons .btn_disabled img {
  opacity: 0.2;
  cursor: default;
}

#sideToolButtons .btn_disabled:hover>img {
  opacity: 0.2;
  cursor: default;
}

#calcButton {
  position: absolute;
  bottom: 50px;
  width: 30px !important;
  right: 50%;
  margin-right: -10px !important;
  display: none;
}

#designConsole {
  width: 100%;
  position: absolute;
  bottom: 0;
  height: 60%;
  min-height: 180px;
  margin-bottom: 0;
}

#innerConsole {
  position: relative;
  color: #333;
  height: 100%;
  min-height: 40px;
  font-size: 9pt;
  border: #002774 1px solid;
  overflow: hidden;
  padding: 3px 6px;
}

#innerConsole:hover {
  overflow: auto;
}

#innerConsole>p {
  margin: 0;
  padding: 0 !important;
  text-align: left;
  margin-bottom: 5px !important;
}

.lastEntry {
  font-weight: bold;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<fieldset class="step">
  <legend id="stepTitle_2">Line Design</legend>
  <div id="stepDesc_2" class="txtbox">
    Make a sketch of the required line design. The composition and length of the channels are visible if you draw or adapt the line.
  </div>
  <div id="toolsWrapper" class="form-group">
    <label id='drawtoggle' class="col-md-3">
                                <input type="radio" id="penToggle" name="mouseToggle" value=0 checked>
                                <img src="./images/draw.png">
                            </label>
    <label id='cursortoggle' class="col-md-3">
                                <input type="radio" id="selToggle" name="mouseToggle" value=1>
                                <img src="./images/cursor.png">
                            </label>
    <div id="sideToolButtons" class="form-group">

      <button type="button" id="delButton" class="col-md-6" style="margin-left: 20px;">
                                    <img src="./images/trash.png" alt=""/>
                                </button>

      <button type="button" id="zoomFitButton" class="col-md-6" style="margin-left: 20px;">
                                    <img src="./images/zoom_fit.png" alt=""/>
                                </button>


    </div>
    <div id="designConsole" class="form-group">
      <!-- <div id="designDefinitions" class = "col-md-6"></div> -->
      <div id="innerConsole" class="col-md-12"></div>
    </div>
  </div>
  <div id="designContainer"></div>
</fieldset>

谢谢你。

标签: htmlcssbootstrap-4

解决方案


推荐阅读