CSS 奇思妙想边框动画
今天逛博客网站 — shoptalkshow,看到这样一个界面,非常有意思: 觉得它的风格很独特,尤其是其中一些边框。 嘿嘿,所以来一篇边框特辑,看看运用 CSS,可以在边框上整些什么花样。 border 属性 谈到边框,首先会想到 border,我们最常用的莫过于 solid,dashed,上图中便出现了 dashed。 除了最常见的 solid,dashed,CSS border 还支持 none,hidden, dotted, double, groove, ridge, inset, outset 等样式。除去 none,hidden,看看所有原生支持的 border 的样式: 基础的就这些,如果希望实现一个其他样式的边框,或者给边框加上动画,那就需要配合一些其他属性,或是脑洞大开。OK,一起来看看一些额外的有意思的边框。 边框长度变化 先来个比较简单的,实现一个类似这样的边框效果: 这里其实是借用了元素的两个伪元素。两个伪元素分别只设置上、左边框,下、右边框,通过 hover 时改变两个伪元素的高宽即可。非常好理解。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
<span class="hljs-selector-tag">div</span> { <span class="hljs-attribute">position</span>: relative; <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid <span class="hljs-number">#03A9F3</span>; &::before, &::after { <span class="hljs-attribute">content</span>: <span class="hljs-string">""</span>; <span class="hljs-attribute">position</span>: absolute; <span class="hljs-attribute">width</span>: <span class="hljs-number">20px</span>; <span class="hljs-attribute">height</span>: <span class="hljs-number">20px</span>; } &<span class="hljs-selector-pseudo">::before</span> { <span class="hljs-attribute">top</span>: -<span class="hljs-number">5px</span>; <span class="hljs-attribute">left</span>: -<span class="hljs-number">5px</span>; <span class="hljs-attribute">border-top</span>: <span class="hljs-number">1px</span> solid <span class="hljs-built_in">var</span>(--borderColor); <span class="hljs-attribute">border-left</span>: <span class="hljs-number">1px</span> solid <span class="hljs-built_in">var</span>(--borderColor); } &<span class="hljs-selector-pseudo">::after</span> { <span class="hljs-attribute">right</span>: -<span class="hljs-number">5px</span>; <span class="hljs-attribute">bottom</span>: -<span class="hljs-number">5px</span>; <span class="hljs-attribute">border-bottom</span>: <span class="hljs-number">1px</span> solid <span class="hljs-built_in">var</span>(--borderColor); <span class="hljs-attribute">border-right</span>: <span class="hljs-number">1px</span> solid <span class="hljs-built_in">var</span>(--borderColor); } &<span class="hljs-selector-pseudo">:hover</span><span class="hljs-selector-pseudo">::before</span>, &<span class="hljs-selector-pseudo">:hover</span><span class="hljs-selector-pseudo">::after</span> { <span class="hljs-attribute">width</span>: <span class="hljs-built_in">calc</span>(<span class="hljs-number">100%</span> + <span class="hljs-number">9px</span>); <span class="hljs-attribute">height</span>: <span class="hljs-built_in">calc</span>(<span class="hljs-number">100%</span> + <span class="hljs-number">9px</span>); } } <span class="copy-code-btn">复制代码</span> |
CodePen Demo — width border animation 接下来,会开始加深一些难度。 虚线边框动画 使用 dashed 关键字,可以方便的创建虚线边框。
|
1 2 3 4 5 |
<span class="hljs-selector-tag">div</span> { <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> dashed <span class="hljs-number">#333</span>; } <span class="copy-code-btn">复制代码</span> |
当然,我们的目的是让边框能够动起来。使用 dashed 关键字是没有办法的。但是实现虚线的方式在 CSS 中有很多种,譬如渐变就是一种很好的方式:
|
1 2 3 4 5 6 |
<span class="hljs-selector-tag">div</span> { <span class="hljs-attribute">background</span>: <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">90deg</span>, #<span class="hljs-number">333</span> <span class="hljs-number">50%</span>, transparent <span class="hljs-number">0</span>) repeat-x; <span class="hljs-attribute">background-size</span>: <span class="hljs-number">4px</span> <span class="hljs-number">1px</span>; <span class="hljs-attribute">background-position</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span>; } <span class="copy-code-btn">复制代码</span> |
看看,使用渐变模拟的虚线如下: 好,渐变支持多重渐变,我们把容器的 4 个边都用渐变表示即可:
|
1 2 3 4 5 6 7 8 9 10 |
<span class="hljs-selector-tag">div</span> { <span class="hljs-attribute">background</span>: <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">90deg</span>, #<span class="hljs-number">333</span> <span class="hljs-number">50%</span>, transparent <span class="hljs-number">0</span>) repeat-x, <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">90deg</span>, #<span class="hljs-number">333</span> <span class="hljs-number">50%</span>, transparent <span class="hljs-number">0</span>) repeat-x, <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">0deg</span>, #<span class="hljs-number">333</span> <span class="hljs-number">50%</span>, transparent <span class="hljs-number">0</span>) repeat-y, <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">0deg</span>, #<span class="hljs-number">333</span> <span class="hljs-number">50%</span>, transparent <span class="hljs-number">0</span>) repeat-y; <span class="hljs-attribute">background-size</span>: <span class="hljs-number">4px</span> <span class="hljs-number">1px</span>, <span class="hljs-number">4px</span> <span class="hljs-number">1px</span>, <span class="hljs-number">1px</span> <span class="hljs-number">4px</span>, <span class="hljs-number">1px</span> <span class="hljs-number">4px</span>; <span class="hljs-attribute">background-position</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span>, <span class="hljs-number">0</span> <span class="hljs-number">100%</span>, <span class="hljs-number">0</span> <span class="hljs-number">0</span>, <span class="hljs-number">100%</span> <span class="hljs-number">0</span>; } <span class="copy-code-btn">复制代码</span> |
效果如下: OK,至此,我们的虚线边框动画其实算是完成了一大半了。虽然 border-style: dashed 不支持动画,但是渐变支持呀。我们给上述 div 再加上一个 hover 效果,hover 的时候新增一个 animation 动画,改变元素的 background-position 即可。
|
1 2 3 4 5 6 7 8 9 10 |
<span class="hljs-selector-tag">div</span><span class="hljs-selector-pseudo">:hover</span> { <span class="hljs-attribute">animation</span>: linearGradientMove .<span class="hljs-number">3s</span> infinite linear; } <span class="hljs-keyword">@keyframes</span> linearGradientMove { 100% { <span class="hljs-attribute">background-position</span>: <span class="hljs-number">4px</span> <span class="hljs-number">0</span>, -<span class="hljs-number">4px</span> <span class="hljs-number">100%</span>, <span class="hljs-number">0</span> -<span class="hljs-number">4px</span>, <span class="hljs-number">100%</span> <span class="hljs-number">4px</span>; } } <span class="copy-code-btn">复制代码</span> |
OK,看看效果,hover 上去的时候,边框就能动起来,因为整个动画是首尾相连的,无限循环的动画看起来就像是虚线边框在一直运动,这算是一个小小的障眼法或者小技巧: 这里还有另外一个小技巧,如果我们希望虚线边框动画是从其他边框,过渡到虚线边框,再行进动画。完全由渐变来模拟也是可以的,如果想节省一些代码,使用 border 会更快一些,譬如这样:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<span class="hljs-selector-tag">div</span> { <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid <span class="hljs-number">#333</span>; &:hover { <span class="hljs-attribute">border</span>: none; <span class="hljs-attribute">background</span>: <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">90deg</span>, #<span class="hljs-number">333</span> <span class="hljs-number">50%</span>, transparent <span class="hljs-number">0</span>) repeat-x, <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">90deg</span>, #<span class="hljs-number">333</span> <span class="hljs-number">50%</span>, transparent <span class="hljs-number">0</span>) repeat-x, <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">0deg</span>, #<span class="hljs-number">333</span> <span class="hljs-number">50%</span>, transparent <span class="hljs-number">0</span>) repeat-y, <span class="hljs-built_in">linear-gradient</span>(<span class="hljs-number">0deg</span>, #<span class="hljs-number">333</span> <span class="hljs-number">50%</span>, transparent <span class="hljs-number">0</span>) repeat-y; <span class="hljs-attribute">background-size</span>: <span class="hljs-number">4px</span> <span class="hljs-number">1px</span>, <span class="hljs-number">4px</span> <span class="hljs-number">1px</span>, <span class="hljs-number">1px</span> <span class="hljs-number">4px</span>, <span class="hljs-number">1px</span> <span class="hljs-number">4px</span>; <span class="hljs-attribute">background-position</span>: <span class="hljs-number">0</span> <span class="hljs-number">0</span>, <span class="hljs-number">0</span> <span class="hljs-number">100%</span>, <span class="hljs-number">0</span> <span class="hljs-number">0</span>, <span class="hljs-number">100%</span> <span class="hljs-number">0</span>; } } <span class="copy-code-btn">复制代码</span> |
由于 border 和 background 在盒子模型上位置的差异,视觉上会有一个很明显的错位的感觉: 要想解决这个问题,我们可以把 border 替换成 outline,因为 outline […]
View Detailsnpm ERR! Unexpected end of JSON input while parsing near
You are trying to create a new angular, react, vue app, and you end up with an error message saying: npm ERR! Unexpected end of JSON input while parsing near There’s a high chance that your npm cache been damaged. Try:
|
1 |
npm cache clean --force |
If you are a windows user, try deleting all files in this folder:
|
1 |
C:\Users{{your-username}}\AppData\Roaming\npm-cache |
Then…
|
1 |
npm cache verify |
If that doesn’t work, try updating to the lastest (understand the risks)
|
1 |
npm i npm@latest -g |
I hope this helps! from:https://dev.to/rishiabee/npm-err-unexpected-end-of-json-input-while-parsing-near-743
View DetailsVue 魔法师 —— 将 API “类化”
前言 【类】和【接口】是 JavaScript 未来的方向,我们的 API 调用也将如此,朝着这个方向和业务模块同步分类、同步升级。本文讲的正是 —— Vue 魔法师,如何将 API “类化”? 万物皆模块,万物可归类。闲言少叙,直接正题。 分类 API 环境: Vue2+ 或 Vue3+ 咱这里直接 VueCLI 迅速快捷构建
|
1 |
vue create vue-api-module |
得到如下目录
|
1 2 3 4 5 |
--src ----store ------index.js ----App.vue ----main.js |
然后新建文件 api.js 如下,
|
1 2 3 4 5 6 7 |
--src ----services ------api.js ----store ------index.js ----App.vue ----main.js |
基础类 API 我们先创建一个基础类如下:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
class BaseApiService { baseUrl = "https://jsonplaceholder.typicode.com"; resource; constructor(resource) { if (!resource) throw new Error("Resource is not provided"); this.resource = resource; } getUrl(id = "") { return `${this.baseUrl}/${this.resource}/${id}`; } handleErrors(err) { // 处理错误: console.log({ message: "Errors is handled here", err }); } } |
baseUrl:设置请求根路径; resource:来源; getUrl:获取链接函数,包含 baseUrl、resource、id; handleErrors:处理错误函数; 只读类 API 然后,我们再创建一个子类:包含 fetch、get 只读方法。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
class ReadOnlyApiService extends BaseApiService { constructor(resource) { super(resource); } async fetch(config = {}) { try { const response = await fetch(this.getUrl(), config); return await response.json(); } catch (err) { this.handleErrors(err); } } async get(id) { try { if (!id) throw Error("Id 不合法"); const response = await fetch(this.getUrl(id)); return await response.json(); } catch (err) { this.handleErrors(err); } } } |
fetch:获取数据; get:通过 id 获取数据; 写入类 API 接着,我们再创建一个包含可读写方法的子类:post、put、delete
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
class ModelApiService extends ReadOnlyApiService { constructor(resource) { super(resource); } async post(data = {}) { try { const response = await fetch(this.getUrl(), { method: "POST", body: JSON.stringify(data) }); const { id } = response.json(); return id; } catch (err) { this.handleErrors(err); } } async put(id, data = {}) { if (!id) throw Error("Id 不合法"); try { const response = await fetch(this.getUrl(id), { method: "PUT", body: JSON.stringify(data) }); const { id: responseId } = response.json(); return responseId; } catch (err) { this.handleErrors(err); } } async delete(id) { if (!id) throw Error("Id 不合法"); try { await fetch(this.getUrl(id), { method: "DELETE" }); return true; } catch (err) { this.handleErrors(err); } } } |
post:创建数据; put:更新数据; delete:删除数据; 继承 让我们看看两个简单的继承示例:
|
1 2 3 4 5 |
class UsersApiService extends ReadOnlyApiService { constructor() { super("users"); } } |
|
1 2 3 4 5 |
class PostsApiService extends ModelApiService { constructor() { super("posts"); } } |
【UsersApiService 类】继承了只读类 API —— ReadOnlyApiService,可以使用 fetch、get 两种方法。而 【PostsApiService 类】继承了读写类 API —— ModelApiService,可以使用 fetch、get、post、put、delete 五种方法。 我们也可以根据业务来写继承 API 类:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
class AlbumsApiService extends ModelApiService { constructor() { super("albums"); } async uploadImage() { /* 这里可以写你的上传图片逻辑 */ console.log({ message: "图片上传成功!" }); return true; } async triggerError() { try { throw Error(" API 模块调用错误!"); } catch (err) { this.handleErrors(err); } } } |
导出 我们在 api.js 导出这些 […]
View DetailsRGB颜色参考
实色效果 英文名称 R.G.B 16色 实色效果 英文名称 R.G.B 16色 Snow 255 250 250 #FFFAFA PaleTurquoise1 187 255 255 #BBFFFF GhostWhite 248 248 255 #F8F8FF PaleTurquoise2 174 238 238 #AEEEEE WhiteSmoke 245 245 245 #F5F5F5 PaleTurquoise3 150 205 205 #96CDCD Gainsboro 220 220 220 #DCDCDC PaleTurquoise4 102 139 139 #668B8B FloralWhite 255 250 240 #FFFAF0 CadetBlue1 152 245 255 #98F5FF OldLace 253 245 230 #FDF5E6 CadetBlue2 142 229 238 #8EE5EE Linen 250 240 230 #FAF0E6 CadetBlue3 122 197 205 #7AC5CD AntiqueWhite 250 235 215 #FAEBD7 CadetBlue4 83 134 139 #53868B […]
View Detailsc# base64转字符串
转成 Base64 形式的 System.String:
|
1 2 3 4 5 |
string a = "base64字符串与普通字符串互转"; byte[] b = System.Text.Encoding.Default.GetBytes(a); //转成 Base64 形式的 System.String a = Convert.ToBase64String(b); Response.Write(a); |
转回到原来的 System.String:
|
1 2 3 |
byte[] c = Convert.FromBase64String(a); a = System.Text.Encoding.Default.GetString(c); Response.Write(a);<br> |
from:https://www.cnblogs.com/daimaxuejia/p/12893207.html
View Detailsjs实现保存文件到本地
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
function fake_click(obj) { var ev = document.createEvent("MouseEvents"); ev.initMouseEvent( "click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null ); obj.dispatchEvent(ev); } function download(name, data) { var urlObject = window.URL || window.webkitURL || window; var downloadData = new Blob([data]); var save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a") save_link.href = urlObject.createObjectURL(downloadData); save_link.download = name; fake_click(save_link); } //调用方法 download("save.txt","内容"); |
from:https://www.cnblogs.com/frost-yen/p/10226705.html
View Detailsc# 确定dynamic类型的数据对象是否存在某个属性
|
1 2 3 4 5 6 |
public static bool IsPropertyExist(dynamic data, string propertyname) { if (data is ExpandoObject) return ((IDictionary<string, object>)data).ContainsKey(propertyname); return data.GetType().GetProperty(propertyname) != null; } |
https://www.cnblogs.com/94cool/p/8135579.html
View Detailsjs解析websocket二进制数据包
js解释数据包 做一个项目,服务器要给我发一个数据包,格式为,前面16位short,后32位int,后面就全是string,我用javascript怎么去把这个数据包解读出来? 用WebSocket,接收到的就是一个Blob对象.而我要给服务器返回的也是这种格式,我又怎么把我的数据封装成这样的数据包? ——解决方案——————--
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
var reader = { readAs: function(type,blob,cb){ var r = new FileReader(); r.onloadend = function(){ if(typeof(cb) === 'function') { cb.call(r,r.result); } } try{ r['readAs'+type](blob); }catch(e){} } } function parseBlob(blob){ var shortVar, intVar, stringVar; reader.readAs('ArrayBuffer',blob.slice(0,2),function(arr){ shortVar = (new Int16Array(arr))[0]; console.log(shortVar); }); reader.readAs('ArrayBuffer',blob.slice(2,6),function(arr){ intVar = (new Int32Array(arr))[0]; console.log(intVar); }); reader.readAs('Text',blob.slice(6,blob.size,'text/plain;charset=UTF-8'),function(result){ stringVar = result; console.log(stringVar); }); } var buffer = new ArrayBuffer(6);//建立6个字节的缓冲,前两个字节是short,后四个是int var bufferView = new Int16Array(buffer); //建立16位的视图,那么视图的长度应该是3 bufferView[0] = 32767; bufferView[1] = 0; bufferView[2] = 1; //现在buffer中的内容由低位到高位应该是 //11111111 11111110 00000000 00000000 100000000 00000000 var blob = new Blob([bufferView,"words words 文本文本文本文本"]); //构造这个blob类型 //测试一下parseBlob函数是否正确 parseBlob(blob); //32767 //65536 //words words 文本文本文本文本 //第一个short是32767 //第二个int,前16位为0,第17位为1,所以结果是65536 //第三个字符串,和我们构造blob的时候一样 |
from:https://blog.csdn.net/woxingwosu0100/article/details/51273523/
View DetailsJS字符串与二进制的相互转化
|
1 2 3 4 5 |
//字符串转ascii码,用charCodeAt(); //ascii码转字符串,用fromCharCode(); var str = "A"; var code = str.charCodeAt(); var str2 = String.fromCharCode(code); |
十进制转二进制
|
1 2 3 |
var a = "i"; console.log(a.charCodeAt()); //105 console.log(a.charCodeAt().toString(2)); //1101001 |
|
1 2 3 |
var a = "我"; console.log(a.charCodeAt()); //25105 console.log(a.charCodeAt().toString(2)); //110001000010001 |
|
1 2 3 4 |
var a = "我们"; console.log(a.length); //2 var list = a.split(""); console.log(list.length); //2<br>console.log(a.charCodeAt().toString(2)); //110001000010001 100111011101100 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
//将字符串转换成二进制形式,中间用空格隔开 function strToBinary(str){ var result = []; var list = str.split(""); for(var i=0;i<list.length;i++){ if(i != 0){ result.push(" "); } var item = list[i]; var binaryStr = item.charCodeAt().toString(2); result.push(binartStr); } return result.join(""); } console.log(strToBinary("我们")); //110001000010001 100111011101100 console.log(strToBinary("@%$+")); //1000000 100101 100100 101011 //将二进制字符串转换成Unicode字符串 function binaryToStr(str){ var result = []; var list = str.split(" "); for(var i=0;i<list.length;i++){ var item = list[i]; var asciiCode = parseInt(item,2); var charValue = String.fromCharCode(asciiCode); result.push(charValue); } return result.join(""); } console.log(binaryToStr("110001000010001 100111011101100")); //我们 console.log(binaryToStr("1000000 100101 100100 101011")); //@%$+ |
转载请注明出处:http://www.cnblogs.com/it-deepinmind/ from:https://www.cnblogs.com/it-deepinmind/p/7430025.html
View Detailsdocker从容器里面拷文件到宿主机或从宿主机拷文件到docker容器里面
1、从容器里面拷文件到宿主机? 答:在宿主机里面执行以下命令 docker cp 容器名:要拷贝的文件在容器里面的路径 要拷贝到宿主机的相应路径 示例: 假设容器名为testtomcat,要从容器里面拷贝的文件路为:/usr/local/tomcat/webapps/test/js/test.js, 现在要将test.js从容器里面拷到宿主机的/opt路径下面,那么命令应该怎么写呢? 答案:在宿主机上面执行命令
|
1 |
docker cp testtomcat:/usr/local/tomcat/webapps/test/js/test.js /opt |
2、从宿主机拷文件到容器里面 答:在宿主机里面执行如下命令 docker cp 要拷贝的文件路径 容器名:要拷贝到容器里面对应的路径 示例:假设容器名为testtomcat,现在要将宿主机/opt/test.js文件拷贝到容器里面的/usr/local/tomcat/webapps/test/js路径下面,那么命令该怎么写呢? 答案:在宿主机上面执行如下命令
|
1 |
docker cp /opt/test.js testtomcat:/usr/local/tomcat/webapps/test/js |
3、在这里在记录一个问题,怎么看容器名称? 执行命令:docker ps,出现如图所示,其中NAMES就是容器名了。 4.需要注意的是,不管容器有没有启动,拷贝命令都会生效。 from:https://www.cnblogs.com/areyouready/p/8973495.html
View Details