OM The Eternity
OM The Eternity

Reputation: 16234

HTML/CSS: Display image in semicircle in top of modal box

I have a requirement of displaying the image/icon on top of the modal box in a semicircle. Though I have achieved it with the help of below code, but the only issue is whenever my form in the modal box goes for a validation check, displaying any error, my semicircle doesn't get adjusted accordingly, rather it stays at its position. Here, I have attached the screen shot of what exactly I am looking for and HTML/css code I have used to display the semicircle with image/icon at the top.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>

NOTE: This is a mobile view screenshot

Upvotes: 1

Views: 651

Answers (2)

user7561863
user7561863

Reputation:

Just adjust your css code into something like this:

.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;
}

Just remove the bottom: 300px; and replace with top: -48px; or any value that you want.

Upvotes: 1

Huy Nguyen
Huy Nguyen

Reputation: 434

please add top:-15px; and removed bottom:300px; in class .modal-wrapper::after { top: -15px; }, u will see the image move up

Upvotes: 1

Related Questions