Pure CSS to add style to select (no script) implementation

Pure CSS to add style to select (no script) implementation
Change the default style of select, usually through ul,li to simulate to achieve.
There are many Jquery plug-ins that change the default select style in this way.
According to the feedback from the programmer, this method cannot obtain data after the form is submitted. Later, after experiments, different JS/Jquery plug-ins were used, and the result was the same: the data could not be obtained.

Later, I read a blog written by a foreigner. He used CSS style to add a div outside the select, set the width of the select to be smaller than the width of the parent div, and then change the style of the default arrow of the select by setting the background attribute of the div.
This method is a good method. It does not require writing scripts, but only uses pure CSS to implement it.

However, this method also has flaws. In the IE series, there will be a background color block when a certain option is selected. IE7-IE10 all have this bug.
In Opera, the background image of the div is not displayed, that is, the drop-down arrow of the select is not displayed. I don't know what the reason is.
The following code

Copy code
The code is as follows:

<div class="select_style">
<select name="select">
<option>AAAAAAAAAAA</option>
<option>BBBBBBBBBBB</option>
<option selected>CCCCCCCCCCC</option>
<option>DDDDDDDDDD</option>
</select>
</div>


Copy code
The code is as follows:

.select_style {width:240px; height:30px; overflow:hidden; background:url(../images/arrow.png) no-repeat 215px;
border:1px solid #ccc;
-moz-border-radius: 5px; /* Gecko browsers */
-webkit-border-radius: 5px; /* Webkit browsers */
border-radius:5px;
}
.select_style select { padding:5px; background:transparent; width:268px; font-size: 16px; border:none; height:30px;
-webkit-appearance: none; /*for Webkit browsers*/
}

<<:  Detailed process of installing and deploying onlyoffice in docker

>>:  MySQL restores data through binlog

Recommend

The solution of html2canvas that pictures cannot be captured normally

question First, let me talk about the problem I e...

Vue implements horizontal scrolling of marquee style text

This article shares the specific code for Vue to ...

Difference between querySelector and getElementById methods in JS

Table of contents 1. Overview 1.1 Usage of queryS...

Summary of MySQL InnoDB architecture

Table of contents introduction 1. Overall archite...

Summary of Vue first screen performance optimization component knowledge points

Vue first screen performance optimization compone...

Vue3 slot usage summary

Table of contents 1. Introduction to v-slot 2. An...

Docker uses root to enter the container

First run the docker container Run the command as...

A brief discussion on the synchronization solution between MySQL and redis cache

Table of contents 1. Solution 1 (UDF) Demo Case 2...

Vue implements drag and drop or click to upload pictures

This article shares the specific code of Vue to a...

MySQL5.7 master-slave configuration example analysis

MySQL5.7 master-slave configuration implementatio...

Win2008 Server Security Check Steps Guide (Daily Maintenance Instructions)

The document has been written for a while, but I ...