css 图像突出边框

w6mmgewl  于 2023-02-06  发布在  其他
关注(0)|答案(2)|浏览(160)

图像从白色边框中移出,我希望它位于边框内部:

body {
  margin: 0px;
}

div.container {
  height: 100vh;
  background-image: url("https://i.imgur.com/AQI5SzX.jpeg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: bottom;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

div.whitebox {
  position: relative;
  left: -5%;
  width: 75%;
  height: 75%;
  background-color: white;
  border-radius: 3%;
}

div.titleclass {
  position: relative;
  height: 30vh;
  overflow: hidden;
}

div.overlay {
  position: absolute;
  background-color: #bdb76b6b;
  background-image: url("https://i.imgur.com/vah2G4d.jpeg");
  background-blend-mode: screen;
  background-size: cover;
  opacity: 0.9;
  transform: rotate(7deg) translate(-2.3%, -20%);
  height: 50vh;
  width: 105%;
}

div.title {
  font-family: "Rockwell";
  font-size: 3.5vw;
  text-align: left;
  color: #006400;
  font-weight: 400;
  font-style: normal;
  position: relative;
  top: 25px;
  left: 20px;
}
<div class="container">
  <div class="whitebox">
    <div class="content">
      <div class="titleclass">
        <div class="overlay"></div>
        <div class="title">MODULO ISCRIZIONE SOFTAIR</div>
      </div>
    </div>
  </div>
</div>
<script src="Modulo_softair_rework.js"></script>
3duebb1j

3duebb1j1#

去掉高度:75%并使用顶部重新定位

body {
  margin: 0px;
}

div.container {
  height: 100vh;
  background-image: url("https://i.imgur.com/AQI5SzX.jpeg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: bottom;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

div.whitebox {
  position: relative;
  left: -5%;
  top:-25%;
  width: 75%;
  
  background-color: white;
  border-radius: 3%;
}

div.titleclass {
  position: relative;
  height: 30vh;
  overflow: hidden;
}

div.overlay {
  position: absolute;
  background-color: #bdb76b6b;
  background-image: url("https://i.imgur.com/vah2G4d.jpeg");
  background-blend-mode: screen;
  background-size: cover;
  opacity: 0.9;
  transform: rotate(7deg) translate(-2.3%, -20%);
  height: 50vh;
  width: 105%;
}

div.title {
  font-family: "Rockwell";
  font-size: 3.5vw;
  text-align: left;
  color: #006400;
  font-weight: 400;
  font-style: normal;
  position: relative;
  top: 25px;
  left: 20px;
}
<div class="container">
  <div class="whitebox">
    <div class="content">
      <div class="titleclass">
        <div class="overlay"></div>
        <div class="title">MODULO ISCRIZIONE SOFTAIR</div>
      </div>
    </div>
  </div>
</div>
<script src="Modulo_softair_rework.js"></script>
1l5u6lss

1l5u6lss2#

添加溢出:隐藏到具有边界半径的父div。

body {
  margin: 0px;
}

div.container {
  height: 100vh;
  background-image: url("https://i.imgur.com/AQI5SzX.jpeg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: bottom;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

div.whitebox {
  position: relative;
  left: -5%;
  width: 75%;
  height: 75%;
  background-color: white;
  border-radius: 3%;
  /*here is the change */
  /*here is the change */
  /*here is the change */
  overflow: hidden;
}

div.titleclass {
  position: relative;
  height: 30vh;
  overflow: hidden;
}

div.overlay {
  position: absolute;
  background-color: #bdb76b6b;
  background-image: url("https://i.imgur.com/vah2G4d.jpeg");
  background-blend-mode: screen;
  background-size: cover;
  opacity: 0.9;
  transform: rotate(7deg) translate(-2.3%, -20%);
  height: 50vh;
  width: 105%;
}

div.title {
  font-family: "Rockwell";
  font-size: 3.5vw;
  text-align: left;
  color: #006400;
  font-weight: 400;
  font-style: normal;
  position: relative;
  top: 25px;
  left: 20px;
}
<div class="container">
  <div class="whitebox">
    <div class="content">
      <div class="titleclass">
        <div class="overlay"></div>
        <div class="title">MODULO ISCRIZIONE SOFTAIR</div>
      </div>
    </div>
  </div>
</div>
<script src="Modulo_softair_rework.js"></script>

相关问题