Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
天就來分享一些網頁中會用到的展示的小效果
很多欄目的邊框當鼠標移上去的時候,邊框會有移動的色澤變化,有順時針過渡或者逆時針過渡的效果
下面看看效果:
實現代碼:
一篇文章我們說了單行文本框和多行文本框,今天呢我們繼續看一下表單的其它控件:單選框、復選框、下拉框。
在我們表單頁面中,經常會有選擇性別或者選擇愛好這類的內容,使用選擇框是一個好主意,html中有兩種選擇框,即單選框和復選框,兩者的區別是單選框中的選項用戶只能選擇一項,而復選框中用戶可以任意選擇多項,甚至全選。
使用語法:
單選框:<input type="radio" value="值" name="名稱" checked="checked"/>
復選框:<input type="checkbox" value="值" name="名稱" checked="checked"/>
詳細講解:
1、type: 當 type="radio" 時,控件為單選框;當 type="checkbox" 時,控件為復選框
2、value:提交數據到服務器的值(后臺程序使用)
3、name:為控件命名,這里要注意同一組的單選按鈕,name 取值一定要一致(具體可見下邊的參考練習)。
4、checked:當設置 checked="checked"(也可以直接簡寫成checked) 時,該選項被默認選中
使用練習:
我們創建一個表單,表單里邊包含姓別(男、女)選擇的單選框,默認選中男以及愛好(唱歌、打游戲、繪畫、旅游)選擇的多選框,默認選中唱歌。具體的代碼如下圖所示:
在網頁中的顯示效果就如下圖所示:
下拉框也是我們常用的一個表單控件,多用于選擇城市地區等。
使用語法:
<select>
<option value="向服務器提交的內容" selected="selected">網頁顯示的內容</option>
</select>
詳細講解:
1、option:option為select下拉子元素,可以有一個或多個,寫法類似ul和li,其中的value內容為提交數據到服務器的值(后臺程序使用)
2、selected:當設置 selected="selected"(也可以直接簡寫成selected) 時,該選項被默認選中
使用練習:
我們創建一個表單,表單里邊包含一個城市的下拉框,下拉框中有北京、上海、天津這三個城市,其中默認選中天津。具體的代碼如下圖所示:
在網頁中的顯示效果就如下圖所示:
好了,本篇文章就先給大家介紹這幾個表單控件的語法以及使用,下篇文章我們將介紹按鈕的語法及使用以及完整的表單練習演示,記得平時要多加練習才是王道。
每日金句:做人要像竹子一樣每前進一步,都要做一次小結。喜歡我的文章的小伙伴記得關注一下哦,每天將為你更新最新知識。
sweetalert2是一個漂亮的、響應式、可定制的替代JAVASCRIPT原生的彈出框插件。sweetalert2相比sweetalert更加強大,但它不是sweetalert的擴展,它是一個全新的插件,且支持三大流行前端框架React、Vue、Angular。
https://github.com/sweetalert2/sweetalert2
https://sweetalert2.github.io/
提供了很多安裝方式
npm install --save sweetalert2
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>
注意:如果想要兼容IE11,還得引入polyfill.js
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.js"></script>
// ES6 Modules or TypeScript import Swal from 'sweetalert2' // CommonJS const Swal = require('sweetalert2')
Swal.fire('基本信息彈框')
Swal.fire( '標題下有文字', '標題下的文字?', 'question' )
Swal.fire({ type: 'error', title: '標題', text: '出錯啦!', footer: '<a href>為什么會出錯?</a>' })
Swal.fire({ title: '<strong>HTML <u>示例</u></strong>', type: 'info', html: '你可以使用自定義的html<a , showCloseButton: true, showCancelButton: true, focusConfirm: false, confirmButtonText: '好的', confirmButtonAriaLabel: '看起來不錯', cancelButtonText: '取消', cancelButtonAriaLabel: '取消', })
Swal.fire({ position: 'top-end', type: 'success', title: '你的修改以保存', showConfirmButton: false, timer: 1500 })
Swal.fire({ title: '確定要刪除么?', text: "刪除后將無法撤銷!", type: 'warning', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: '確定', cancelButtonText:'取消' }).then((result) => { if (result.value) { Swal.fire( '刪除成功!', '文件已被刪除', 'success' ) } })
Swal.fire({ title: '標題', text: '自定義圖片', imageUrl: 'https://unsplash.it/400/200', imageWidth: 400, imageHeight: 200, imageAlt: 'Custom image', animation: false })
Swal.fire({ title: '自定義寬度、邊框和背景', width: 600, padding: '3em', background: '#fff url(/images/trees.png)', })
let timerInterval Swal.fire({ title: '自動關閉的彈框!', html: '我會在<strong></strong> 秒后關閉.', timer: 2000, onBeforeOpen: () => { Swal.showLoading() timerInterval = setInterval(() => { Swal.getContent().querySelector('strong') .textContent = Swal.getTimerLeft() }, 100) }, onClose: () => { clearInterval(timerInterval) } }).then((result) => { if ( // Read more about handling dismissals result.dismiss === Swal.DismissReason.timer ) { console.log('I was closed by the timer') } })
Swal.fire({ title: '提交用戶名', input: 'text', inputAttributes: { autocapitalize: 'off' }, showCancelButton: true, confirmButtonText: '提交', cancelButtonText: '取消', showLoaderOnConfirm: true, preConfirm: (login) => { return fetch(`//api.github.com/users/${login}`) .then(response => { if (!response.ok) { throw new Error(response.statusText) } return response.json() }) .catch(error => { Swal.showValidationMessage( `請求出錯: ${error}` ) }) }, allowOutsideClick: () => !Swal.isLoading() }).then((result) => { if (result.value) { Swal.fire({ title: `${result.value.login}'s avatar`, imageUrl: result.value.avatar_url }) } })
Swal.mixin({ input: 'text', confirmButtonText: '下一步', showCancelButton: true, cancelButtonText:'取消', progressSteps: ['1', '2', '3'] }).queue([ { title: '問題1', text: '使用modal很簡單?' }, '問題2', '問題3' ]).then((result) => { if (result.value) { Swal.fire({ title: '所有問題回答完成!', html: '你的答案是: <pre><code>' + JSON.stringify(result.value) + '</code></pre>', confirmButtonText: 'Lovely!' }) } })
這里就簡單介紹這些示例,更多示例詳見官方文檔
https://github.com/sweetalert2/ngx-sweetalert2
https://github.com/sweetalert2/sweetalert2-react-content
https://github.com/sweetalert2/sweetalert2-webpack-demo
https://github.com/sweetalert2/sweetalert2-parcel-demo
https://github.com/avil13/vue-sweetalert2
https://github.com/realrashid/sweet-alert
sweetalert2是原本sweetalert的升級版,功能更加強大,文檔更加全面,寫法更加先進,是Web開發中常用的插件,當然同樣優秀的還有很多,比如國產的layer.js也很好用,選擇一個適合自己的就成,今天的介紹就到這里,希望能對你有所幫助,如果還有更好的推薦,歡迎到評論區留言,謝謝!
*請認真填寫需求信息,我們會在24小時內與您取得聯系。