A complete guide to some uncommon but useful CSS attribute operations

A complete guide to some uncommon but useful CSS attribute operations

1. Custom text selection

::selection {
  background: red;
  color: black;
}

2. Remove the download button in the video controls

video::-internal-media-controls-download-button {
    display:none;
}

video::-webkit-media-controls-enclosure {
    overflow:hidden;
}

video::-webkit-media-controls-panel {
    width: calc(100% + 30px); 
}

3. What is the function of transform: translateZ(0) in CSS3?

GPU acceleration to optimize front-end performance

4. Scroll bar style modification

/* * You can change other selectors*/
*::-webkit-scrollbar {
    width: 2px;
  height: 2px;
}
*::-webkit-scrollbar-thumb {
  border-radius: 5px;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  background: #00063a;
}
*::-webkit-scrollbar-track {
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
    border-radius: 0;
  background: #00063a;
}

5. Input type number hides up and down buttons

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
}
input[type="number"]{
    -moz-appearance:textfield;
}

6. CSS gradient virtual frame

<style>
    .box {
        width: 150px;
        border: 2px dashed #fff;
        background: linear-gradient(to bottom, #34538b, #cd0000);
        background-origin: border-box;
    }
    .content {
        height: 100px;
        background-color: #fff;
    }
</style>
<div class="box">
    <div class="content"></div>
</div> 

Gradient virtual frame

7. Border gradient color rounded corners

<style type="text/css">
	.content { 
		width: 100px; 
	   	height: 100px; 
	    box-sizing: border-box; 
	    padding: 5px; 
	    border-radius: 50%; 
	    background-image: -webkit-linear-gradient(top, red 0%, blue 30%, yellow 60%, green 90%);  
	    background-image: -moz-linear-gradient(top, red 0%, blue 30%, yellow 60%, green 90%); 
	    background-image: linear-gradient(top, red 0%, blue 30%, yellow 60%, green 90%);  
	}
	.box { 
		width:100%; 
	    height:100%; 
	    border-radius:50%; 
	    background:#fff; 
	}
</style>
<div class="content">
	<div class="box"></div>
</div> 

Gradient rounded corners

8. The cursor of the input box changes color, but the text does not change color

input{
    caret-color: red;
} 

Insert image description here Cursor color change

9. Tapered Gradient

.box {
    width: 300px; height: 300px;
    background: conic-gradient(from 45deg, white, black, white);
} 

Tapered gradient

10. Text-decoration to achieve wavy lines

wavy
    display: block;
    height: .5em;
    white-space: nowrap;
    letter-spacing: 100vw;
    padding-top: .5em;
    overflow: hidden;
}
wavy::before {
    content: "\2000\2000";
    /* IE browser solid line instead*/
    text-decoration: overline;
    /* Modern browsers */
    text-decoration: overline wavy;
} 

Wavy Lines

11. CSS Triangle

<style type="text/css" media="screen">
.div1{
	width: 0;
	height: 0;
	border: 100px solid;
	<!--Top right bottom left-->
	border-color: red transparent transparent transparent;
}
</style>
<div class="div1"></div> 

insert image description here

12. CSS background gradient and background image coexist

background: url(https://img.alicdn.com/imgextra/i4/1881744325/O1CN01JBktT81hotb8c6Py0_!!1881744325.png) center no-repeat, linear-gradient(to bottom, red, #3c3f40); 

insert image description here

13. Customize browser scroll bar

/*Define the scroll bar width, height and background. The width and height correspond to the size of the horizontal and vertical scroll bars respectively*/
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
    background-color: rgba(245, 245, 245, 0.47);
}
 
/*Define the scroll bar track, inner shadow and rounded corners*/
::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
    border-radius: 10px;
    background-color: #f5f5f5;
}
 
/*Define slider, inner shadow and rounded corners*/
::-webkit-scrollbar-thumb {
    /*width: 10px;*/
    height: 20px;
    border-radius: 10px;
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
    background-color: rgba(85, 85, 85, 0.25);
}

14. Change the font color and size of the placeholder

input::-webkit-input-placeholder { 
    /* WebKit browsers */ 
    font-size:14px;
    color: #333;
} 
input::-moz-placeholder { 
    /* Mozilla Firefox 19+ */ 
    font-size:14px;
    color: #333;
} 
input:-ms-input-placeholder { 
    /* Internet Explorer 10+ */ 
    font-size:14px;
    color: #333;
}

This concludes this article about some uncommon but very useful CSS attribute operations. For more relevant CSS attribute operation content, please search 123WORDPRESS.COM’s previous articles or continue to browse the related articles below. I hope that everyone will support 123WORDPRESS.COM in the future!

<<:  Implementation of Nginx configuration https

>>:  avue-crud implementation example of multi-level complex dynamic header

Recommend

Detailed explanation of vue.js dynamic components

:is dynamic component Use v-bind:is="compone...

How to use bind to set up DNS server

DNS (Domain Name Server) is a server that convert...

Tutorial diagram of installing mysql8.0.18 under linux (Centos7)

1 Get the installation resource package mysql-8.0...

How to use positioning to center elements (web page layout tips)

How to center an element in the browser window He...

JavaScript implements password box input verification

Sometimes it is necessary to perform simple verif...

Centos 7 64-bit desktop version installation graphic tutorial

If you think the system is slow and want to chang...

How to use crontab to add scheduled tasks in Linux

Preface The Linux system is controlled by the sys...

Zookeeper unauthorized access test problem

Table of contents Preface Detect Zookeeper servic...

iframe multi-layer nesting, unlimited nesting, highly adaptive solution

There are three pages A, B, and C. Page A contains...

How to run Hadoop and create images in Docker

Reinventing the wheel, here we use repackaging to...

MySQL trigger definition and usage simple example

This article describes the definition and usage o...

Installation and configuration method of vue-route routing management

introduce Vue Router is the official routing mana...

Tutorial on installing mysql8 on linux centos7

1. RPM version installation Check if there are ot...

Implementation steps of vue-element-admin to build a backend management system

Recently, when I was working on a conference heal...

Install Docker for Windows on Windows 10 Home Edition

0. Background Hardware: Xiaomi Notebook Air 13/In...