Home > Web Front-end > Front-end Q&A > Can input change css style?

Can input change css style?

藏色散人
Release: 2023-01-04 09:38:17
Original
1902 people have browsed it

Input can change the css style. The method of modifying the css style is: 1. Use pseudo-class elements to change the radio style; 2. Use the label to point to the input and change the label style to achieve the effect.

Can input change css style?

The operating environment of this tutorial: Dell G3 computer, Windows 7 system, HTML5&&CSS3 version.

Recommended: "css video tutorial"

How to change the default css style of the input box:

Can input change css style?

1: Use pseudo-class elements to change the radio style (this method does not require adding additional labels, it is more convenient)

  .div input[type=radio]::after {
    position: absolute;
    width: 25px;
    height: 25px;
    background: url(../img/inputBG.jpg) no-repeat;
    background-size: 100% 100%;
  }
Copy after login

2: Use label to point to input, and achieve the effect by changing the label style

<html>  
    <input type="checkbox" checked="checked" id="aa"/><label for="aa"></label>
  </html>
  <style>
    input[type=checkbox]{
       visibility: hidden;
    }
    label{
      width:20px;
      height:20px;
      border:1px solid #707070;
    }
    input[type=checkbox]:checked + label{
      background: url(../img/duigou.jpg)no-repeat;
      background-size: 100% 100%;
    }
  </style>
Copy after login

The above is the detailed content of Can input change css style?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template