Home Web Front-end CSS Tutorial How to use css to remove the default style assigned by the browser to a form

How to use css to remove the default style assigned by the browser to a form

Apr 02, 2017 am 10:39 AM

When we write a form, we will find that some browsers assign default styles to the form. For example, in the Chrome browser, the text box and drop-down selection box will have glowing borders when they load focus, and in Firefox and Google Chrome, the multiline text boxtextarea can be freely dragged and enlarged. In addition, under IE10, when content is entered in the text box, a small cross will appear on the right side of the text box. Fork, wait. There is no doubt that these effects have improved the user experience, but sometimes we don’t need these default styles, so what should we do? Let's take a look at the solutions separately.

1. Remove the default glowing border of the text box in browsers such as Chrome

input:focus, textarea:focus {
    outline: none;
}
Copy after login

Remove the highlight style:

input:focus{
    -webkit-tap-highlight-color:rgba(0,0,0,0);
    -webkit-user-modify:read-write-plaintext-only;
}
Copy after login

Of course this is the case Since then, when the text box loads the focus, the border of the text box under all browsers will not change in color or style, but we can set it again according to our own needs, such as:

input:focus,textarea:focus {
    outline: none;
    border: 1px solid #f60;
}
Copy after login

In this case, when the text box loads the focus, the border color will change to orange, giving the user a feedback.

2. Remove the small cross behind the text box in IE10+ browser

Just the following sentence is ok

input::-ms-clear {
    display: none;
}
Copy after login

3. Prohibit multiple lines Drag the text box textarea

In this way, click the following to addattributesThe multi-line text box cannot be dragged to zoom in or out:

textarea {
    resize: none;
}
Copy after login

Required here Mentioned an attribute resize, this is a CSS3 attribute, used for element scaling, it can take the following values:

none default value

both allows horizontal and vertical scaling

horizontal only allows horizontal scaling

vertical only allows vertical scaling

It can be applied not only to textarea elements, but also to most elements, such as divs, etc., not here List them one by one, but unlike textarea, you need to add the sentence overflow: auto; when using div, that is, this will be effective:

div {
    resize: both;
    overflow: auto;
}
Copy after login

The above is the detailed content of How to use css to remove the default style assigned by the browser to a form. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is apache server? What is apache server for? What is apache server? What is apache server for? Apr 13, 2025 am 11:57 AM

Apache server is a powerful web server software that acts as a bridge between browsers and website servers. 1. It handles HTTP requests and returns web page content based on requests; 2. Modular design allows extended functions, such as support for SSL encryption and dynamic web pages; 3. Configuration files (such as virtual host configurations) need to be carefully set to avoid security vulnerabilities, and optimize performance parameters, such as thread count and timeout time, in order to build high-performance and secure web applications.

Tips for using HDFS file system on CentOS Tips for using HDFS file system on CentOS Apr 14, 2025 pm 07:30 PM

The Installation, Configuration and Optimization Guide for HDFS File System under CentOS System This article will guide you how to install, configure and optimize Hadoop Distributed File System (HDFS) on CentOS System. HDFS installation and configuration Java environment installation: First, make sure that the appropriate Java environment is installed. Edit /etc/profile file, add the following, and replace /usr/lib/java-1.8.0/jdk1.8.0_144 with your actual Java installation path: exportJAVA_HOME=/usr/lib/java-1.8.0/jdk1.8.0_144exportPATH=$J

How to configure HTTPS server in Debian OpenSSL How to configure HTTPS server in Debian OpenSSL Apr 13, 2025 am 11:03 AM

Configuring an HTTPS server on a Debian system involves several steps, including installing the necessary software, generating an SSL certificate, and configuring a web server (such as Apache or Nginx) to use an SSL certificate. Here is a basic guide, assuming you are using an ApacheWeb server. 1. Install the necessary software First, make sure your system is up to date and install Apache and OpenSSL: sudoaptupdatesudoaptupgradesudoaptinsta

How to monitor HDFS status on CentOS How to monitor HDFS status on CentOS Apr 14, 2025 pm 07:33 PM

There are many ways to monitor the status of HDFS (Hadoop Distributed File System) on CentOS systems. This article will introduce several commonly used methods to help you choose the most suitable solution. 1. Use Hadoop’s own WebUI, Hadoop’s own Web interface to provide cluster status monitoring function. Steps: Make sure the Hadoop cluster is up and running. Access the WebUI: Enter http://:50070 (Hadoop2.x) or http://:9870 (Hadoop3.x) in your browser. The default username and password are usually hdfs/hdfs. 2. Command line tool monitoring Hadoop provides a series of command line tools to facilitate monitoring

Nginx performance monitoring and troubleshooting tools Nginx performance monitoring and troubleshooting tools Apr 13, 2025 pm 10:00 PM

Nginx performance monitoring and troubleshooting are mainly carried out through the following steps: 1. Use nginx-V to view version information, and enable the stub_status module to monitor the number of active connections, requests and cache hit rate; 2. Use top command to monitor system resource occupation, iostat and vmstat monitor disk I/O and memory usage respectively; 3. Use tcpdump to capture packets to analyze network traffic and troubleshoot network connection problems; 4. Properly configure the number of worker processes to avoid insufficient concurrent processing capabilities or excessive process context switching overhead; 5. Correctly configure Nginx cache to avoid improper cache size settings; 6. By analyzing Nginx logs, such as using awk and grep commands or ELK

What are the steps to install GitLab in Debian What are the steps to install GitLab in Debian Apr 13, 2025 am 10:33 AM

The steps to install GitLab in the Debian system are as follows: Update the system package: sudoapt-getupdate Installation Dependencies: sudoapt-getinstall-ycurlopenssh-serverca-certificatestzdataperl Add GitLab official repository: curlhttps://packages.gitlab.com/install/reposit

The relationship between nginx and web server The relationship between nginx and web server Apr 14, 2025 am 07:09 AM

nginx is a lightweight, non-blocking web server and reverse proxy, commonly used for front-end proxy, load balancing, and caching. Its relationship with a web server is usually: Front-end proxy: nginx handles requests and forwards them to the back-end server. Load Balancer: nginx distributes requests to multiple backend servers. Caching: nginx caches frequently accessed files for performance.

How to build a website in nginx How to build a website in nginx Apr 14, 2025 am 11:21 AM

Using Nginx to build a website is carried out in five steps: 1. Install Nginx; 2. Configure Nginx, mainly configuring the listening port, website root directory, index file and error page; 3. Create website files; 4. Test Nginx; 5. Advanced configuration can be carried out as needed, such as SSL encryption, reverse proxy, load balancing and caching.

See all articles