@mSolo
        
        2015-05-13T06:38:03.000000Z
        字数 11706
        阅读 1361
    HTML5 CSS3 Bootstrap
HTML5: from documents to applications
An overview of the new DOM APIs in HTML5:
- 2D Canvas
 - Audio and Video
 - Drag and Drop
 - Cross-document Messaging
 - Server-sent Events
 - WebSockets
 - Document Editing
 - Web Storage
 - Offline Web Applications
 
The new form input types introduced in HTML5
| Type | ||||
|---|---|---|---|---|
| color | date | datetime | datetime-local | |
| month | number | range | search | tel | 
| time | url | week | 
HTML5’s new input element attributes
| Attribute | ||||
|---|---|---|---|---|
| autocomplete | autofocus | list | max | min | 
| multiple | pattern | placeholder | required | step | 
A partial list of the new features in CSS3
| New selectors | New pseudo-classes | Rounded borders | Border images | 
|---|---|---|---|
| Gradients | Box shadow | Box sizing | Background sizing | 
| Text shadow | Word wrapping | Multiple columns | Web fonts | 
| Multiple backgrounds | Alpha color channels | Media queries | Speech style | 
| Transitions | Animations | 3D transforms | 2D transforms | 
<progress value="50" max="100"></progress><meter min="0" max="10" low="3" high="7" optimum="9" value="0"></meter><details><summary>Section Heading</summary>This is an example of using <details> and <summary>to create collapsible content without using JavaScript.</details>

<link rel="stylesheet" href="style.css"><script src="modernizr.js"></script><script src="app.js"></script>
<form name="order" method="post" action="/submit"><h1>Order Form</h1><fieldset><legend>Contact Details</legend><ul><li><label class="required"><div>Full Name</div><input name="name" required autofocus></label></li><li><label class="required"><div>Email Address</div><input type="email" name="email" required></label></li><li><label><div>Postal Address</div><input name="address1" placeholder="Address Line 1"></label><div> </div><input name="address2" placeholder="Address Line 2"><div> </div><input name="city" class="city" placeholder="Town/City"><input name="state" class="state" placeholder="State"><input name="zip" class="zip" placeholder="Zip Code"><div> </div><select name="country"><option value="0">Country</option><option value="US">United States</option><option value="CA">Canada</option></select></li><li><label><div>Home Phone No.</div><input type="tel" name="homephone"></label></li><li><label><div>Cell Phone No.</div><input type="tel" name="cellphone"></label></li><li><label><div>Skype Name</div><input name="skype"></label></li><li><label><div>Twitter</div><span class="twitter_prefix">@</span><input name="twitter" class="twitter"></label></li></ul></fieldset><fieldset><legend>Login Details</legend><ul><li><label class="required"><div>Password</div><input type="password" name="password" required></label></li><li><label class="required"><div>Confirm Password</div><input type="password" name="confirm_password" required></label></li></ul></fieldset><fieldset><legend>Order Details</legend><table><thead><tr><th>Product Code</th><th>Description</th><th>Qty</th><th>Price</th><th>Total</th></tr></thead><tbody><tr><td>COMP001<input type="hidden" name="product_code" value="COMP001"></td><td>The Ultimate Smartphone</td><td><input type="number" data-price="399.99" name="quantity"value="0" min="0" max="99" maxlength="2"></td><td>$399.99</td><td><output name="item_total" class="item_total">$0.00</output></td></tr><tr><td>COMP002<input type="hidden" name="product_code" value="COMP002"></td><td>The Ultimate Tablet</td><td><input type="number" data-price="499.99" name="quantity"value="0" min="0" max="99" maxlength="2"></td><td>$499.99</td><td><output name="item_total" class="item_total">$0.00</output> </td></tr><tr><td>COMP003<input type="hidden" name="product_code" value="COMP003"></td><td>The Ultimate Netbook</td><td><input type="number" data-price="299.99" name="quantity"value="0" min="0" max="99" maxlength="2"></td><td>$299.99</td><td><output name="item_total" class="item_total">$0.00</output></td></tr></tbody><tfoot><tr><td colspan="4">Order Total</td><td><output name="order_total" id="order_total">$0.00</output></td></tr></tfoot></table></fieldset><fieldset><legend>Payment Details</legend><ul><li><label class="required"><div>Name on Card</div><input name="card_name" required></label></li><li><label class="required"><div>Credit Card No.</div><input name="card_number" pattern="[0-9]{13,16}"maxlength="16" required title="13-16 digits, no spaces"></label></li><li><label class="required"><div>Expiry Date</div><input type="month" name="card_expiry" maxlength="7"placeholder="YYYY-MM" required value="2015-06"></label></li><li><label class="required"><div>CVV2 No.</div><input name="card_cvv2" class="cvv" maxlength="3"pattern="[0-9]{3}" required title="exactly 3 digits"><span>(Three digit code at back of card)</span></label></li></ul></fieldset><div class="buttons"><input type="submit" value="Submit Order"><input type="submit" id="saveOrder" value="Save Order" formnovalidate formaction="/save"></div></form>
(function() {var init = function() {var orderForm = document.forms.order,saveBtn = document.getElementById('saveOrder'),saveBtnClicked = false;var saveForm = function() {if(!('formAction' in document.createElement('input'))) {var formAction = saveBtn.getAttribute('formaction');orderForm.setAttribute('action',formAction);}saveBtnClicked = true;};saveBtn.addEventListener('click',saveForm, false);var qtyFields = orderForm.quantity,totalFields = document.getElementsByClassName('item_total'),orderTotalField = document.getElementById('order_total');var formatMoney = function(value) {return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");}var calculateTotals = function() {var i = 0,ln = qtyFields.length,itemQty = 0,itemPrice = 0.00,itemTotal = 0.00,itemTotalMoney = '$0.00',orderTotal = 0.00,orderTotalMoney = '$0.00';for(;i<ln;i++) {if(!!qtyFields[i].valueAsNumber) {itemQty =qtyFields[i].valueAsNumber || 0; // HTML5 version} else {itemQty =parseFloat(qtyFields[i].value) || 0; // Fallback version}if(!!qtyFields[i].dataset) {itemPrice =parseFloat(qtyFields[i].dataset.price);} else {itemPrice =parseFloat(qtyFields[i].getAttribute('data-price'));}itemTotal =itemQty *itemPrice;itemTotalMoney = '$'+formatMoney(itemTotal.toFixed(2));orderTotal +=itemTotal;orderTotalMoney = '$'+formatMoney(orderTotal.toFixed(2));if(!!totalFields[i].value) {totalFields[i].value =itemTotalMoney;orderTotalField.value =orderTotalMoney;} else {totalFields[i].innerHTML =itemTotalMoney;orderTotalField.innerHTML =orderTotalMoney;}}};calculateTotals();var qtyListeners = function() {var i = 0,ln = qtyFields.length;for(;i<ln;i++) {qtyFields[i].addEventListener('input',calculateTotals, false);qtyFields[i].addEventListener('keyup',calculateTotals, false);}};qtyListeners();var doCustomValidity = function(field, msg) {if('setCustomValidity' in field) {field.setCustomValidity(msg);} else {field.validationMessage = msg;}};var validateForm = function() {doCustomValidity(orderForm.name, '');doCustomValidity(orderForm.password, '');//...if(!Modernizr.inputtypes.month || !Modernizr.input.pattern) {fallbackValidation();}if(orderForm.name.value.length < 4) {doCustomValidity(orderForm.name, 'Full Name must be at least 4 characters long');}//...};orderForm.addEventListener('input', validateForm, false);orderForm.addEventListener('keyup', validateForm, false);var styleInvalidForm = function() {orderForm.className = 'invalid';}orderForm.addEventListener('invalid', styleInvalidForm, true);Modernizr.load({test: Modernizr.inputtypes.month,nope: 'monthpicker.js'});var getFieldLabel = function(field) {if('labels' in field && field.labels.length > 0) {return field.labels[0].innerText;}if(field.parentNode && field.parentNode.tagName.toLowerCase()=== 'label') {return field.parentNode.innerText;}return '';}var submitForm = function(e) {if(!saveBtnClicked) {validateForm();var i = 0,ln = orderForm.length,field,errors = [],errorFields = [],errorMsg = '';for(; i<ln; i++) {field = orderForm[i];if( (!!field.validationMessage && field.validationMessage.length > 0) ||(!!field.checkValidity && !field.checkValidity()) ) {errors.push(getFieldLabel(field)+': '+field.validationMessage);errorFields.push(field);}}if(errors.length > 0) {e.preventDefault();errorMsg = errors.join('\n');alert('Please fix the following errors:\n'+errorMsg, 'Error');orderForm.className = 'invalid';errorFields[0].focus();}}};orderForm.addEventListener('submit', submitForm, false);var fallbackValidation = function() {var i = 0,ln = orderForm.length,field;for(;i<ln;i++) {field = orderForm[i];doCustomValidity(field, '');if(field.hasAttribute('pattern')) {var pattern = new RegExp(field.getAttribute('pattern').toString());if(!pattern.test(field.value)) {var msg = 'Please match the requested format.';if(field.hasAttribute('title') && field.getAttribute('title').length > 0) {msg += ' '+field.getAttribute('title');}doCustomValidity(field, msg);}}if(field.hasAttribute('type') &&field.getAttribute('type').toLowerCase()=== 'email') {var pattern = new RegExp(/\S+@\S+\.\S+/);if(!pattern.test(field.value)) {doCustomValidity(field, 'Please enter an email address.');}}if(field.hasAttribute('required') && field.value.length < 1) {doCustomValidity(field, 'Please fill out this field.');}}};};window.addEventListener('load',init, false);}) ();
html, body, form, fieldset, legend, h1, ul {margin: 0;padding: 0;border: 0;outline: 0;font-weight: inherit;font-style: inherit;font-size: 100%;font-family: inherit;vertical-align: baseline;font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight: 300;}form {width: 800px; margin: 30px auto;background-color: #DCD4CE;border: 1px solid #423021;box-shadow: 2px 2px 10px #666;}h1 {background-color: #BEB0A3;border-bottom: 1px solid #423021;font-size: 2em; font-weight: 600;padding: 5px 15px;text-shadow: 1px 1px 0px #fff;}fieldset {border: none; margin: 20px 20px;border-bottom: 1px dashed #BEB0A3; padding-bottom: 20px;}legend {display: block; font-weight: bold; font-size: 1.25em;width: 100%; padding-bottom: 10px;text-shadow: 1px 1px 0px #fff;}input:not([type=submit]), select {border: 1px solid #999;padding: 2px;}input:required, select:required {background-color: lightyellow;}form.invalid input:invalid, form.invalid select:invalid,form.invalid input.invalid, form.invalid select.invalid {background-color: #FFD4D4;border: 1px solid maroon;}ul {list-style-type: none;}li {display: block; width: 380px; float: left;}li div {width: 130px; float: left; margin-top: 5px;color: #444; font-size: 0.8em; font-weight: 300;}li label.required div {font-weight: bold;}li label span {font-size: 11px; font-weight: 300; color: #333;}li input, li select {width: 225px; margin-bottom: 5px;font-size: 0.9em;}span.twitter_prefix { color: #666; font-size: .95em; font-weight: bold; }input.city { width: 80px; margin-right: 0; }input.state { width: 35px; margin-right: 0; }input.zip { width: 90px; }input.twitter { width: 206px; }table {width: 100%;border: 1px solid #705536;border-collapse: collapse;box-shadow: 1px 1px 10px #666;}th, td {border: 1px solid #705536;padding: 5px 10px;}th {text-shadow: 1px 1px 0px #000; font-weight: bold;}thead th:nth-child(1), thead th:nth-child(2) {text-align: left;}thead th:nth-child(4), thead th:nth-child(5) {text-align: right;}tbody tr td {background-color: #e5dad2;}tbody tr:nth-child(even) td {background-color: #fff3e9;}tbody td:nth-child(1) {width: 110px;}tbody td:nth-child(3) {width: 60px; text-align: center;}td input {width: 50px; height: 28px; font-size: 1.1em; text-align: right;}tbody td:nth-child(4) {width: 60px; text-align: right;}tbody td:nth-child(5) {width: 80px; text-align: right;}th {background-color: #614023;color: #fff;}tfoot td {background-color: #BEB0A3;text-align: right; font-weight: bold;font-size: 1.15em;text-shadow: 1px 1px 0px #fff;}input[type=month] { width: 100px; }input.cvv { width: 60px; text-align: right; }.buttons {margin: 15px 20px 10px; text-align: right;}input[type=submit], input[type=button] {border: 1px solid #423021;background-color: #896640;color: #fff; padding: 6px 10px;border-radius: 6px;text-shadow: 1px 1px 0px #000;font-size: 0.9em; cursor: pointer;font-weight: bold;background-image: -webkit-linear-gradient(top, #896640 0%, #705536 100%);# -moz-linear-gradient, -o-linear-gradient, -ms-linear-gradientbackground-image: linear-gradient(to bottom, #896640 0%, #705536 100%);}input[type=submit]:active, input[type=button]:active {background-color: #705536;background-image: -webkit-linear-gradient(bottom, #896640 0%, #705536 100%);#}.placeholder {color: #999;}.month-picker-month { width: 115px; }.month-picker-year { width: 55px; text-align: right; }