HTML / CSS:在模式框顶部以半圆显示图像

时间:2018-08-16 07:39:29

标签: html css bootstrap-modal

我需要在半圆的模态框顶部显示图像/图标。尽管我是通过以下代码实现的,但是唯一的问题是,每当我在模式框中的表单进行验证检查,显示任何错误时,我的半圆都不会相应地进行调整,而是停留在其位置。在这里,我附上了我要查找的内容的屏幕快照以及用于显示半圆并在顶部显示图像/图标的HTML / css代码。Expected Design Design distortion on validation message

.modal {
  font-family: Avenir-Medium;
  font-size: 16px;
  font-weight: 900;
  font-style: normal;
  font-stretch: normal;
  display: block;
  /*Hidden by default */
  position: fixed;
  /* Stay in place */
  z-index: 1;
  /* Sit on top */
  left: 0;
  top: 0;
  width: 100%;
  /* Full width */
  height: 100%;
  /* Full height */
  overflow: auto;
  /* Enable scroll if needed */
  background-color: rgb(0, 0, 0);
  /* Fallback color */
  background-color: rgba(0, 0, 0, 0.3);
  /* Black w/ opacity */
  -webkit-animation-name: slideIn;
  /* Fade in the background */
  -webkit-animation-duration: 2.0s;
  /* Fade in the background */
  ;
}


/* Modal Content */

.modal-content {
  position: fixed;
  bottom: 0;
  background-color: #fefefe;
  width: 92%;
  left: 14px;
  -webkit-animation-name: fadeIn;
  -webkit-animation-duration: 0.5s;
  border-radius: 16px 16px 0px 0px;
  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  box-shadow: none;
  border: none;
  top: auto;
}

.modal-wrapper {
  line-height: 45px;
  border: 1px solid #e7e9ea;
  border-radius: 6px 6px 0px 0px;
  background-color: white;
  margin: auto;
}

.modal-wrapper::after {
  background: url("../../../../images/mobile/img-payment_38.png") no-repeat 22px 10px;
  background-size: 50%;
  background-color: #fff;
  content: '';
  width: 78px;
  height: 45px;
  position: absolute;
  left: 0;
  right: 0;
  margin: auto;
  border-radius: 78px 78px 0 0;
  border-left: 1px solid #e7e9ea;
  border-top: 1px solid #e7e9ea;
  border-right: 1px solid #e7e9ea;
  border-bottom: 3px solid white;
  bottom: 300px;
}

.close-btn {
  position: absolute;
  vertical-align: top;
  top: 4px;
  left: 320px;
  width: 18px;
  height: 18px;
}

.container-div-creditCard {
  margin: 12px 20px 0px 20px;
}

.container-div-creditCard>img {
  position: absolute;
  bottom: 154px;
  right: 30px;
}

.credit-card-modal-label {
  font-family: AvenirHeavy;
  font-size: 13px;
  color: #1d3444;
  text-align: center;
  font-weight: 200;
  height: 24px;
  margin-left: 31px;
}

.input-modal {
  width: 100%;
  height: 44px;
}

.input-spacing {
  margin-top: 15px;
}

.credit-input-modal {
  border: solid 1px #e7e9ea;
  border-radius: 5px;
  font-family: Avenir-Book;
  font-size: 14px;
  font-weight: normal;
  color: #8589a1;
  line-height: initial;
  padding: 13px 42px 12px 15px;
}

.credit-expiry-input-modal {
  padding: 13px 27px 12px 10px;
  border: solid 1px #e7e9ea;
  border-radius: 5px;
  font-family: Avenir-Book;
  font-size: 14px;
  font-weight: normal;
  color: #8589a1;
  display: inline-block;
  line-height: initial;
  width: 65%;
  height: 44px;
}

.credit-cvc-input-modal {
  width: 30%;
  padding: 17px 5px 12px 10px;
  border: solid 1px #e7e9ea;
  border-radius: 5px;
  font-family: Avenir-Book;
  font-size: 14px;
  font-weight: normal;
  color: #8589a1;
  line-height: initial;
  height: 44px;
}

.cvvDisc {
  -webkit-text-security: disc;
}

.credit-submit-button {
  width: 100%;
  padding: 13px;
  margin-top: 15px;
  border: solid 1px #e7e9ea;
  border-radius: 5px 5px 5px 5px;
  background: linear-gradient(to right, #e32490, #ed1a3d);
  color: white;
  margin-bottom: 20px;
  font-family: Avenir-Book;
  font-weight: normal;
  font-size: 14px;
  line-height: initial;
}

.errorMsg {
  font-family: Avenir-Book;
  font-weight: normal;
  color: #ED1A3D;
  font-size: 12px;
}
<div id="modalCCDetails" class="modal">
  <div class="modal-content modal-wrapper">
    <div class="container-div-creditCard">
      <label class="credit-card-modal-label">ENTER YOUR CREDIT CARD DETAILS</label>
      <input name="cc_name" class="input-modal credit-input-modal" type="text" placeholder="Name printed on Credit Card" onChange={this.handleUserInput} />
      <span class="errorMsg"></span>
      <input name="cc_number" class="input-modal credit-input-modal input-spacing" type="tel" maxLength="16" onKeyPress={(e)=> this.handleCCOnKeyPress(e)} placeholder="16 digit credit card number" />
      <span class="errorMsg"></span>
      <input name="cc_expDate" class="credit-expiry-input-modal" type="text" placeholder="Expiry MM-YYYY" />
      <div class="device-divider" />
      <input name="cc_cvc" class="credit-cvc-input-modal cvvDisc" type="tel" placeholder="CVC" maxLength="3" />
      <span class="errorMsg"></span>
    </div>
    <button class="credit-submit-button">Submit Payment</button>
  </div>
</div>
</div>

注意:这是移动视图的屏幕截图

2 个答案:

答案 0 :(得分:1)

请在类top:-15px;中添加bottom:300px;并删除.modal-wrapper::after { top: -15px; },您会看到图像上移

答案 1 :(得分:0)

只需将您的css代码调整为如下所示:

.modal-wrapper::after {
  background: url("../../../../images/mobile/img-payment_38.png") no-repeat 22px 10px;
  background-size: 50%;
  background-color: #fff;
  content: '';
  width: 78px;
  height: 45px;
  position: absolute;
  left: 0;
  right: 0;
  margin: auto;
  border-radius: 78px 78px 0 0;
  border: 1px solid  #e7e9ea;
  border-bottom: 3px`enter code here` solid white;
  top: -48px;
}

只需移除底部:300px;并替换为top:-48px;或您想要的任何值。