首页 > 其他分享 >html-常用样式或脚本的学习笔记

html-常用样式或脚本的学习笔记

时间:2022-10-28 08:11:56浏览次数:55  
标签:none checkbox .. 样式 笔记 html background webkit border

(一) CSS 样式相关

1. 禁止拖动图片

img {
    -webkit-user-drag: none;
}

2. 去除 select 默认下拉图标

.select {
    appearance:none;
    -webkit-appearance: none;
    background-image: url('../../statics/tir.png');
    background-repeat: no-repeat;
    background-size: 12px;
    background-position: 50px center;
}

3. CSS 限制字数,超出部份显示点点点

.text {
    width: 400px;               /*要显示文字的宽度*/
    text-overflow: ellipsis;    /*让截断的文字显示为点点。还有一个值是clip意截断不显示点点*/
    white-space: nowrap;        /*让文字不换行*/
    overflow: hidden;           /*超出要隐藏*/
}

4. 自定义滚动条

/*滚动条整体样式*/
.main::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 5px;
    height: 10px;
}

/*滚动条里面小方块*/
.main::-webkit-scrollbar-thumb {
    cursor: pointer;
    border-radius: 5px;
    background: #7d7ba0;
    -webkit-transition: color .2s ease;
    transition: color .2s ease;
}

.main::-webkit-scrollbar-thumb:hover {
    background: #7d7ba0;
}

/*滚动条里面轨道*/
.main::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    border-radius: 0;
    background: rgba(0, 0, 0, 0.1);
}

5. 清除浮动

.main:after {
    content: "020";
    display: block;
    clear: both;
    visibility: hidden;
}

6. checkbox 图标的更换

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    appearance: none;
    background: url("../../statics/ic_checkbox_unchecked.png");
    outline: none;
    margin-right: 3px;
    cursor: pointer;
}

input[type=checkbox]:checked{
    background: url("../../statics/ic_checkbox_checked.png");
}

7. 文字不可选中

.text {
    user-select: none;
}

8. 项目中初始化设置 index.css

/* CSS Tools: Reset CSS */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
    display: block;
}
body {
    line-height: 1;
}
ol, ul {
    list-style: none;
}
blockquote, q {
    quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
    content: '';
    content: none;
}
table {
    border-collapse: collapse;
    border-spacing: 0;
}


/* customize */
*,
:after,
:before {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    user-select: none;
    outline: none !important;
}

a {
    cursor: pointer;
    text-decoration: none;
}

body {
    width: 100% !important;
    overflow: hidden;
}

/* 禁止拖动图片 */
img {
    /* pointer-events: none; */
    -webkit-user-drag: none;
}

(二) JavaScript 脚本相关

1. 禁止浏览器的鼠标右键

document.oncontextmenu = function() {
    return false;
}

2. 禁止浏览器的拖拽默认事件

globalDragFile() {
    var globalDragArea = document.querySelector('body')

    globalDragArea.addEventListener('dragover',function(e){
        e.preventDefault()
    })

    globalDragArea.addEventListener('drop', function(e) {
        e.preventDefault()
    })
}

标签:none,checkbox,..,样式,笔记,html,background,webkit,border
From: https://www.cnblogs.com/wanghuizhao/p/16834557.html

相关文章

  • day01-HTML01
    day01-HTML1.JavaWeb技术体系2.B/S软件开发架构简述B/S架构B/S框架,意思是前端(Browser浏览器,小程序,APP,或者自己写的)和服务端(Server)组成的系统的框架结构B/S架构也......
  • docker学习笔记
    @目录前言1docker简介1.1是什么1.1.1为什么会有docker出现1.1.2docker理念1.2容器与虚拟机比较1.2.1容器发展简史1.2.2传统虚拟机技术1.2.3容器虚拟化技术1.2.4......
  • Java开发笔记之EasyExcel实现自定义合并策略
    0x00概述本文转载,原文原本是想学习使用Apache的POI的,但是无意中看到Alibaba的开源工具EastExcel,据说比POI更加快速高效,关键是使用起来也简单。官网地址为:https://aliba......
  • new: 轮播图 | MDN上HTML的总结和CSS面试题解答,以及vue-admin/豆瓣一个静态页面的实现
    主要参看oppo官网https://www.oppo.com/cn/,实现以下功能一、轮播图https://www.cnblogs.com/WindrunnerMax/p/12638005.html通常是在首页读秒播放的图片,本次了解的是opp......
  • 【学习笔记】Mybatis配置优化
    Mybatis配置优化1.核心配置文件结构核心配置文件:mybatis-config.xml官方建议起这个名字,但我们可以随意起名configuration(配置)properties(属性)settings(设置)ty......
  • Basil: A Fast and Byzantine-Resilient Approach for Decentralized Training 阅读笔
    Basil:AFastandByzantine-ResilientApproachforDecentralizedTraining阅读笔记ProblemStatementDecentralizedSystemModel所有训练数据样本存储在分布式节......
  • STM32MP157 LINUX学习笔记01
    开发板IP:192.168.5.9配置命令ifconfigeth0192.168.5.9windowsIP:192.168.5.10ubuntuIP: 192.168.5.11首先确保三者互ping通过 通过这个博客学习如何配置ubuntu......
  • vue-element-admin框架学习笔记
    0背景vue-element-admin是一个已高度完成的系统原型,它基于vue框架和elementUI组件库。它使用最新的前端技术栈,内置i18n国际化解决方案、动态路由、权限验证。它可以帮助......
  • Vue学习笔记之使用computed计算属性
    0x00概述本文主要记录Vue页面使用computed计算属性0x01computed基本使用在computed中定义一个函数(看起来是一个函数,其实是一个属性),命名按照属性规范命名(一般为名词)......
  • HTML5 Canvas基础概念(一)
    Canvas基础知识:Canvas属于行内元素,使用Canvas绘制图形步骤:1、获取Canvas对象2、获取上下文环境对象context。3、开始绘制图形在Canvas对象中常用属性属性说明widthCanvas的......