一个盒子内有4个盒子

文章描述了一个仓库管理系统的界面,涉及重力货位和挂钩货位的货品操作,包括使用不同颜色的el-button进行发货、补货和待机操作。CSS样式定义了按钮和货位区域的布局和样式。

        <div class="levels" v-for="(i, j) in index.levels.slice().reverse()" :key="i"
             v-if="index.name.slice(0,4) == '重力货位' ">
          <!--<el-text class="mx-1" type="primary">{{ i.id }}</el-text>-->
          <div class="cargoCabsOne" v-for="(a,b) in i.cargoCabs" :key="a">
            <div class="gravitySlot">
              <div class="gravitySlotItem">
                <div class="gravitySlotBox">
                  <el-button class="gravitySlotButton" type="primary" plain size="small">{{ a.id }}</el-button>
                </div>
                <div class="gravitySlotBox">
                  <el-button class="gravitySlotButton" type="success" plain>发货</el-button>
                </div>
              </div>

              <div class="gravitySlotItem">
                <div class="gravitySlotBox">
                  <el-button class="gravitySlotButton" type="danger" plain>补货</el-button>
                </div>
                <div class="gravitySlotBox">
                  <el-button class="gravitySlotButton" type="warning" plain>待机</el-button>
                </div>
              </div>

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

css

.gravitySlotItem{
  display: flex;
  align-items: center;
}

.gravitySlotBox {
  margin: 2%;
  background-color: #87ff41;
  flex: 1;
  overflow: hidden;
}

.gravitySlotButton {
  width:100%;
  height: 32px;
}

竖着的

        <div class="levels" v-for="(i, j) in index.levels.slice().reverse()" :key="i"
             v-if="index.name.slice(0,4) == '挂钩货位' ">
          <!--<el-text class="mx-1" type="primary">{{ i.id }}</el-text>-->
          <div class="cargoCabsTwo" v-for="(a,b) in i.cargoCabs" :key="a">
            <div class="hookSlot">
              <div class="hookSlotBox">
                <el-button class="hookSlotButton" type="primary" plain>{{ a.id }}</el-button>
              </div>
              <div class="hookSlotBox">
                <el-button class="hookSlotButton" type="success" plain>发货</el-button>
              </div>
              <div class="hookSlotBox">
                <el-button class="hookSlotButton" type="danger" plain>补货</el-button>
              </div>
              <div class="hookSlotBox">
                <el-button class="hookSlotButton" type="warning" plain>待机</el-button>
              </div>
            </div>
          </div>
        </div>

css

.cargoCabsTwo{
  border: 1px solid red;
  margin: 1%;
  width: 100%;
  /* 隐藏超出父容器宽度的内容 */
  overflow: hidden;
}

.hookSlot {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.hookSlotBox {
  margin: 2%;
  background-color: #ff6a6a;
}

.hookSlotButton {
  height: 100%;
  flex: 1;
  white-space: nowrap;
  font-size: xx-small;
}

CSS 中,如果需要选择并修改容器内最后一个盒子的样式,可以使用 `:last-child` 或 `:last-of-type` 伪类选择器。这两个选择器的作用略有不同,具体取决于目标元素在文档结构中的位置和类型。 ### 使用 `:last-child` 选择最后一个子元素 `:last-child` 伪类选择器用于匹配父元素中最后一个子元素,无论该子元素的类型是什么。如果最后一个子元素是目标盒子,则可以直接应用样式。 例如,假设 HTML 结构如下: ```html <div class="container"> <div class="box">第一个盒子</div> <div class="box">第二个盒子</div> <div class="box">最后一个盒子</div> </div> ``` 可以使用以下 CSS 代码来修改最后一个子元素的样式: ```css .container .box:last-child { background-color: red; } ``` 此代码将 `.box` 类中最后一个子元素的背景颜色设置为红色[^5]。 ### 使用 `:last-of-type` 选择最后一个特定类型的子元素 如果父元素中包含多种类型的子元素,并且需要选择最后一个特定类型的子元素,则可以使用 `:last-of-type` 伪类选择器。该选择器会匹配父元素中最后一个指定类型的子元素。 例如,假设 HTML 结构如下: ```html <div class="container"> <div class="box">第一个盒子</div> <div class="box">第二个盒子</div> <span>这是一个 span 元素</span> </div> ``` 可以使用以下 CSS 代码来修改最后一个 `.box` 元素的样式: ```css .container .box:last-of-type { background-color: blue; } ``` 此代码将 `.box` 类中最后一个特定类型的子元素的背景颜色设置为蓝色[^5]。 ### 注意事项 - 如果父元素中没有指定类型的子元素,则 `:last-of-type` 不会匹配任何内容。 - `:last-child` 与 `:last-of-type` 的区别在于,前者匹配最后一个子元素,而后者匹配最后一个特定类型的子元素。 - 在使用这些选择器时,确保目标元素在其父元素中确实存在,否则选择器不会生效。 --- ### 示例代码 ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>CSS 选择最后一个盒子</title> <style> .container .box:last-child { background-color: red; } .container .box:last-of-type { background-color: blue; } </style> </head> <body> <div class="container"> <div class="box">第一个盒子</div> <div class="box">第二个盒子</div> <div class="box">最后一个盒子</div> <span>这是一个 span 元素</span> </div> </body> </html> ``` --- ###
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值