建企業網站時使用CSS邊框圓角是很容易的事,但要設置邊框圓角的漸變效果就需要費些功夫了,需要正確理解幾個CSS屬性的含義,background-origin,background-clip,background-size這幾個是必須用到的,調整好性能的數值就可以靈活運用了。
想要實現CSS圓角漸變并匹配內容背景圖可以參考以下代碼:
<style> div { width: 500px; height: 300px; margin: 10px; padding: 30px; border-radius: 50px; /*設置圓角*/ border:50px solid transparent; /*設置邊框顏色透明,確保背景漸變色顯示*/ background-origin:border-box; /*從邊框開始背景圖*/ background-clip:padding-box,border-box; /*設置第一個背景和第二個背景的范圍*/ background-size:cover; /*由于背景圖像不能設置純色,所以可以使用下面的方式設置純色*/ background-image:linear-gradient(#fff, #fff),linear-gradient(#FC0, #F30); } .a1{display:block;height:280px;background-image:url(/images/school.jpg); background-repeat:no-repeat;background-size:contain;} </style> <div> <span class="a1">邊框漸變色從內邊框到邊框,背景圖像單獨設置不重復。</span> </div>
background-origin表示的是背景起始位置,其三個值如下,依次是
border-box 從邊框開始;
padding-box(默認) 從內邊距開始;
content-box 從內容開始。
background-origin: border-box | padding-box(默認) | content-box
background-clip表示的是背景填充位置,其四個值如下,依次是
border-box(默認) 填充至邊框;
padding-box 填充至內邊距;
content-box 填充之內容;
text 作為字體前景色。
background-clip: border-box(默認) | padding-box | content-box | text
background-size表示的是背景尺寸,其五個值如下,依次是
contain 將圖像擴大至適應最短的邊,剩余部分默認重復圖像
cover 將圖像擴大至適應最長的邊,圖像可能顯示不完整
length 兩個值依次設置圖像寬和高,未設置則為auto
percentage 兩個百分比依次設置圖像寬和高,未設置則為auto
auto 默認設置
無法訪問可以加企鵝群看離線版:1006429377
或者訪問:https://www.yuque.com/caiyongjie/snknlo/ga5ef9
官網截圖
Print.js was primarily written to help us print PDF files directly within our apps, without leaving the interface, and no use of embeds. For unique situations where there is no need for users to open or download the PDF files, and instead, they just need to print them.
One scenario where this is useful, for example, is when users request to print reports that are generated on the server side. These reports are sent back as PDF files. There is no need to open these files before printing them. Print.js offers a quick way to print these files within our apps.
Print.js主要是為了幫助我們直接在我們的應用程序中打印PDF文件,而無需離開界面,也不使用嵌入。 對于不需要用戶打開或下載PDF文件的獨特情況,相反,他們只需要打印它們。
例如,當用戶請求打印在服務器端生成的報告時,這種情況很有用。 這些報告以PDF文件形式發回。 打印前無需打開這些文件。 Print.js提供了一種在我們的應用程序中打印這些文件的快捷方式。
PDF files must be served from the same domain as your app is hosted under. Print.js uses iframe to load files before printing them, therefore, it is limited by the Same Origin Policy. This helps preventing Cross-site scripting (XSS) attacks.
必須在托管應用程序的同一域中提供PDF文件。 Print.js在打印文件之前使用iframe加載文件,因此它受同源策略的限制。 這有助于防止跨站點腳本(XSS)攻擊。
首先在頁面上添加一個按鈕
<button type="button" onclick="printJS('docs/printjs.pdf')"> Print PDF </button>
<button type="button" onclick="printJS({printable:'docs/xx_large_printjs.pdf', type:'pdf', showModal:true})"> Print PDF with Message </button>
<form method="post" action="#" id="printJS-form"> ... </form> <button type="button" onclick="printJS('printJS-form', 'html')"> Print Form </button>
<button type="button" onclick="printJS({ printable: 'printJS-form', type: 'html', header: 'PrintJS - Form Element Selection' })"> Print Form with Header </button>
<img src="images/print-01.jpg" /> printJS('images/print-01-highres.jpg', 'image') printJS({printable: 'images/print-01-highres.jpg', type: 'image', header: 'My cool image header'})
printJS({ printable: ['images/print-01-highres.jpg', 'images/print-02-highres.jpg', 'images/print-03-highres.jpg'], type: 'image', header: 'Multiple Images', imageStyle: 'width:50%;margin-bottom:20px;' })
someJSONdata = [ { name: 'John Doe', email: 'john@doe.com', phone: '111-111-1111' }, { name: 'Barry Allen', email: 'barry@flash.com', phone: '222-222-2222' }, { name: 'Cool Dude', email: 'cool@dude.com', phone: '333-333-3333' } ] <button type="button" onclick="printJS({printable: someJSONdata, properties: ['name', 'email', 'phone'], type: 'json'})"> Print JSON Data </button>
<button type="button" onclick="printJS({ printable: someJSONdata, properties: ['name', 'email', 'phone'], type: 'json', gridHeaderStyle: 'color: red; border: 2px solid #3971A5;', gridStyle: 'border: 2px solid #3971A5;' })"> Print JSON Data </button>
<button type="button" onclick="printJS({ printable: someJSONdata, properties: [ { field: 'name', displayName: 'Full Name'}, { field: 'email', displayName: 'E-mail'}, { field: 'phone', displayName: 'Phone'} ], type: 'json' })"> Print with custom table header text </button> <button type="button" onclick="printJS({ printable: someJSONdata, type: 'json', properties: ['name', 'email', 'phone'], header: '<h3 class="custom-h3">My custom header</h3>', style: '.custom-h3 { color: red; }' })"> Print header raw html </button>
npm install print-js --save //或 yarn add print-js
import print from 'print-js'
//cdn,不知道能不能訪問,我這可以訪問 https://printjs-4de6.kxcdn.com/print.min.js https://printjs-4de6.kxcdn.com/print.min.cssye <script src="print.js"></script>
<link rel="stylesheet" type="text/css" href="print.css">
詳細配置:
ostbirdAlertBox.js
下載地址:
https://github.com/postbird/PostbirdAlertBox.js
Alert
PostbirdAlertBox.alert({
'title': '提示標題',
'content': '提示內容主體',
'okBtn': '好的',
'contentColor': 'red',
'onConfirm': function () {
console.log("回調觸發后隱藏提示框");
alert("回調觸發后隱藏提示框");
}
});
Confirm
PostbirdAlertBox.confirm({
'title': '提示標題',
'content': '離開本頁面進行跳轉',
'okBtn': '好的',
'contentColor': 'red',
'onConfirm': function () {
console.log("OK - 回調觸發后隱藏提示框");
alert("OK - 回調觸發后隱藏提示框");
},
'onCancel': function () {
console.log("Cancel-回調觸發后隱藏提示框");
alert("Cancel-回調觸發后隱藏提示框");
}
});
Prompt
PostbirdAlertBox.prompt({
'title': '請輸入姓名',
'okBtn': '提交',
onConfirm: function (data) {
console.log("輸入框內容是:" + data);
alert("輸入框內容是:" + data);
},
onCancel: function (data) {
console.log("輸入框內容是:" + data);
alert("輸入框內容是:" + data);
},
});
使用說明
1. 引入js 和 css 文件
2. 通過全局對象 PostbirdAlertBox 調用相關方法,三個方法為: PostbirdAlertBox.alert({}); PostbirdAlertBox.confirm({}); PostbirdAlertBox.prompt({});
配置參數
參數屬性 意義 適用方法 是否必須
title 彈框標題 alert、confirm(不適用于prompt) 否, 默認 : 提示信息
promptTitle prompt標題 prompt 否, 默認 :請輸入內容
content 提示內容主體 alert、confirm(不適用于prompt) 否, 默認 : 提示內容
contentColor 提示內容顏色 alert、confirm 否,默認 : #000000
okBtn 確認按鈕文字 alert、confirm(不適用于prompt) 否, 默認 : 好的
promptOkBtn prompt確認按鈕文字 prompt 否, 默認 : 確認
okBtnColor 確認按鈕顏色 alert、confirm、prompt 否, 默認 : #0e90d2
cancelBtn 取消按鈕文字 alert、confirm、prompt 否, 默認 : 取消
onConfirm 確認按鈕事件 alert、confirm、prompt(存在參數data) 否, 默認 : 不觸發事件
onCancel 取消按鈕事件 alert、confirm、prompt(存在參數data) 否, 默認 : 不觸發事件
參數說明
1. title 和 promptTitle 分開主要是為了方便不傳遞title的情況,prompt和alert、confirm的顯示文字不同
2. okBtn 和 promptOkBtn 分開同樣是為了默認情況下,prompt和alert、confirm的顯示文字不同
3. 正如前面的示例代碼中,prompt的回調函數,會給予一個data參數,用來獲取用戶輸入的內容
*請認真填寫需求信息,我們會在24小時內與您取得聯系。