使用css实现升序,css常见效果实现

一. CSS仿写实心三角特效

1460000022342262

.triangle {

margin: 15px 0 0 130px; // 调整位置

position: absolute;

border: 10px solid white;

border-left-color: transparent;

border-bottom-color: transparent;

border-right-color: transparent;

}

二. Angular美化原生select的下拉选项样式(空心下拉上拉箭头)

1460000022342260

{{name}}

.triangle{

position: absolute; // 控制位置

margin-left: 220px;

margin-top: 10px;

.inner-down { //空心下拉箭头

width: 8px;

height: 8px;

border: 1px solid #CACFD2;

border-width: 1px 1px 0 0;

transform: rotate(135deg);

margin-bottom: 10px;

margin-top: -5px;

}

.inner-up { //空心上拉箭头

width: 8px;

height: 8px;

border: 1px solid #CACFD2;

border-width: 0 0 1px 1px;

transform: rotate(135deg);

margin-bottom: 10px;

}

}

三. Angular - 仿video的拖拉滑动条

1460000022342258

原生JavaScript写法:js原生仿水平拖动轴

.scroll { //总进度条

width: 70%;

height: 5px;

background: #d9e4e7;

position: relative;

margin-top: 15px;

border-radius: 5px;

}

.bar { //控制手柄圈圈

width: 20px;

height: 20px;

background: #fff;

position: absolute;

top: -7px;

left: 0;

cursor: pointer;

border-radius: 50%;

}

.mask { //已走过的进度

position: absolute;

left: 0;

top: 0;

background: #3498db;

width: 0;

height: 5px;

border-radius: 5px;

}

- angular6不能直接通过document对象去操作页面对象!需要以angular特有的方式操作:

1. import { ElementRef } from '@angular/core';

2. constructor(

public element: ElementRef

) { }

3. 通过 **this.element.nativeElement.querySelector('#scroll'); 操作对象!**

videoProgress() {

const _that = this;

const scroll = this.element.nativeElement.querySelector('#scroll'); // 总进度条

const bar = this.element.nativeElement.querySelector('#bar'); // 鼠标按下时拖动的白色小圈圈

const mask = this.element.nativeElement.querySelector('#mask'); // 已走过的蓝色进度

bar.onmousedown = function (event) { // 鼠标按下小圈圈事件

let barleft = 0;

const leftVal = event.clientX - this.offsetLeft;

document.onmousemove = function (event2) { // 鼠标移动事件

barleft = event2.clientX - leftVal;

if (barleft < 0) {

barleft = 0;

} else if (barleft > scroll.offsetWidth - bar.offsetWidth) {

barleft = scroll.offsetWidth - bar.offsetWidth;

}

mask.style.width = barleft + 'px'; // 设置已走过进度长度

bar.style.left = barleft + 'px'; // 设置小圈圈距离起始位置的长度

// 当前已播放的百分比

_that.currentTime = (barleft / (scroll.offsetWidth - bar.offsetWidth)) * (_that.getPlayBackTotalTime);

// 解决若干操作下,例如:鼠标左键已经弹起时候,进度bar还是会跟着鼠标来回滑动,出现类似hover效果的bug!

if (window.getSelection) {

if (window.getSelection().empty) { // Chrome

window.getSelection().empty();

} else if (window.getSelection().removeAllRanges) { // Firefox

window.getSelection().removeAllRanges();

}

}

}

document.onmouseup = function () { // 弹起鼠标不做任何操作

document.onmousemove = null;

}

}

}

四. 原生仿写video播放器

1460000022342261

/

.control-wrapper{

user-select: none;

height: 40px;

line-height: 40px;

width: 100%;

background-color: #000;

border: 1px solid gray;

display: flex;

justify-content: space-between;

}

/* 总进度条 */

.scroll {

width:75%;

height: 6px;

background: #d9e4e7;;

position: relative;

margin: 0 auto;

margin-top: 15px;

border-radius: 5px;

z-index: 999;

}

/* 控制手柄圈圈 */

.bar {

width: 15px;

height: 15px;

background: #fff;

position: absolute;

top: -5px;

left: 0;

cursor: pointer;

border-radius: 50%;

}

/* 已走过的进度 */

.mask {

position: absolute;

left: 0;

top: 0;

background: #3498db;

width: 0;

height: 6px;

border-radius: 5px;

}

/* 音量进度条 */

.scroll_voice{

width:100px;

height: 6px;

background: #d9e4e7;;

position: relative;

margin: 0 auto;

margin-top: 15px;

border-radius: 5px;

z-index: 999;

margin-right: 15px;

}

/* 控制手柄圈圈 */

.bar_voice {

width: 15px;

height: 15px;

background: #fff;

position: absolute;

top: -5px;

left: 0;

cursor: pointer;

border-radius: 50%;

}

/* 已走过的进度 */

.mask_voice {

position: absolute;

left: 0;

top: 0;

background: #3498db;

width: 0;

height: 6px;

border-radius: 5px;

}

// 播放控制进度条

function videoProgress() {

let barleft = 0;

bar.onmousedown = function (event) {

var event = event || window.event;

var leftVal = event.clientX - this.offsetLeft;

$('body').on('mousemove', function () {

var event = event || window.event;

barleft = event.clientX - leftVal;

if (barleft < 0) {

barleft = 0;

} else if (barleft > scroll.offsetWidth - bar.offsetWidth) {

barleft = scroll.offsetWidth - bar.offsetWidth;

}

// 拖动进度条,更新进度条样式,记录拖动百分比 drag_playPercent

drag_playPercent = parseInt(barleft / (scroll.offsetWidth - bar.offsetWidth) * 100);

mask.style.width = drag_playPercent + '%';

bar.style.left = drag_playPercent + "%";

})

$('body').on('mouseup', function () {

$('body').off(); // 去掉所有的事件,解决快速拖拉时候偶现的 hover bug!

...

})

}

}

// 音量控制进度条

function videoVoiceProgress() {

let barleft = 0;

bar_voice.onmousedown = function (event) {

var event = event || window.event;

var leftVal = event.clientX - this.offsetLeft;

$('body').on('mousemove', function (event) {

var event = event || window.event;

barleft = event.clientX - leftVal;

if (barleft < 0) {

barleft = 0;

} else if (barleft > scroll_voice.offsetWidth - bar_voice.offsetWidth) {

barleft = scroll_voice.offsetWidth - bar_voice.offsetWidth;

}

// 拖动进度条,更新进度条样式,记录拖动百分比

drag_voice_playPercent = parseInt(barleft / (scroll_voice.offsetWidth - bar_voice.offsetWidth) * 100);

mask_voice.style.width = drag_voice_playPercent + '%';

bar_voice.style.left = drag_voice_playPercent + "%";

})

$('body').on('mouseup', function () {

$('body').off();

...

})

}

}

五. Angular6 -- 实现列表拖拽和排序

1460000022342259

// 1. 设置被拖拽元素可以拖放 --> 设置 【draggable】 属性

// 2. 设置拖放的元素 --> 【ondragstart】事件中通过 dataTransfer.setData 设置拖放的元素

dragstart(ev: DragEvent, index) {

ev.dataTransfer.setData('Text', index); //传递被拖放元素的索引index

}

// 3. 设置拖放的目的地 --> 被拖放到的目的地 需要在 【ondragover】事件中设置 preventDefault 去允许被放置

dragover(e: Event) {

e.preventDefault();

}

// 4. 放置,重置位置 --> 【drap】事件将对象转移到目的地

drop(e: DragEvent, endIndex) {

e.preventDefault();

// 【dataTransfer.getData】 被拖动的元素所在数组中的index

const startIndex = e.dataTransfer.getData('Text');

const tmp = this.printList[startIndex];

this.printList[startIndex] = this.printList[endIndex]; // 【endIndex】 为目的地的索引值

this.printList[endIndex] = tmp;

}

六. 美化原生滚动轴样式

20:13
视频一 201812180841

...

.m-video-list-wrapper{

height: 732px;

overflow-y: auto;

overflow-x: hidden;

}

.m-video-list-wrapper::-webkit-scrollbar { /*滚动条整体样式*/

/* 控制 y轴 滚动轴的 宽度 */

width: 8px;

/* 控制 x轴 滚动轴的 高度 */

height: 10px;

}

.m-video-list-wrapper::-webkit-scrollbar-track { /*滚动条里面轨道*/

border-radius: 0px;

background-color: #eee;

}

.m-video-list-wrapper::-webkit-scrollbar-thumb { /*滚动条里面小方块*/

border-radius: 5px;

background: rgba(0,0,0,0.2);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值