SmartPay
Challenge 1 of 4
Build & Style The UI
Step 1
- Style the BODY element with a white background color.
- Within the BODY tag, create a DIV and give it a
data-cart-infoattribute. Inside this DIV, create a HEADING element withmdc-typography--headline4"as its CSS class. - The HEADING element should have 2 SPAN children elements. The First SPAN element displays a shopping cart by setting it’s CSS class to
material-iconsand its content toshopping_cart. The second SPAN element should have adata-billattribute and will be used to display the total figure the user is trying to pay on the app. - Create another DIV just after the
data-cart-infoDIV. Give this new DIV adata-credit-cardattribute and set its class tomdc-cardandmdc-card--outlined. Within thedata-credit-cardDIV you just created, add a new DIV with a class ofmdc-card__primary-action. These elements will be styled with the look and feel of an actual credit card. Brace yourself! - Within the
.mdc-card__primary-actionDIV, create an IMAGE with an attribute ofdata-card-typeand set its source to https://placehold.it/120x60.png?text=Card. This IMAGE will be used to display the credit card type (Visa or MasterCard), based on the series of numbers entered by the user. - Right after the IMAGE and still within the
mdc-card__primary-actionDIV, create a new DIV with an attribute ofdata-cc-digits. It should contain four INPUT text fields, each with asizeof4and a placeholder of----(4 dashes). These fields will be used to collect the credit card numbers from the user. - Create a DIV with an attribute of
data-cc-infoas a sibling to thedata-cc-digitsDIV. This new DIV should have two INPUT text fields, one for entering the card holder’s name while the other will be for the card’s expiry date. The first field should have asizeof20and aplaceholderofName Surname. The expiry date field should have asizeof6and aplaceholderofMM/YY- indicating the expiry date format.
We are now done with the structure of the credit card component. Let’s make a button to allow the user make payment with the card details
- Create a BUTTON as a sibling to the
data-credit-cardDIV. Set the BUTTON’s class tomdc-buttonand give it adata-pay-btnattribute. It should havePay Nowas its display text. After the user enters details of the card and clicks on this button, the app will strike-though the card details that are in-valid, if any.
Step 2
While we might have the right structure in place, the app visually tells a different story. Time to make the app look good and usable.
- The SPAN elements within the
data-cart-infoDIV should be displayed as inline block elements and theirvertical-alignset tomiddle. The.material-iconsSPAN should have a150pixels size of font. - Give the
data-credit-cardDIV435pxwidth,240pxminimum height,10pxrounded borders, and a#5d6874background colour. - Display the
data-card-typeIMAGE as a block element. Give it a120pxwidth and a60pxheight. - The
data-cc-digitsDIV should have a2emtop margin. - INPUT elements in the
data-cc-digitsDIV should have a white color,2emfont size and line height, no border or background, and a right margin of0.5em; - The
data-cc-infoDIV should have a1emtop margin. - INPUT elements in the
data-cc-infoDIV should have a white color,1.2emfont size, no border and no background. The second input should also have a right padding of10pxand be floated to the right of the viewport. - The
data-pay-btnBUTTON should have a fixed position,90%width, a solid border of1pxand positioned20pxfrom thebottomof the viewport.
Your app should look better at this point. Ideally, the 4 input fields within the
data-cc-digitsDIV should all be on a single horzontal line