Home Web Front-end HTML Tutorial css去掉iPhone、iPad默认按钮样式_html/css_WEB-ITnose

css去掉iPhone、iPad默认按钮样式_html/css_WEB-ITnose

Jun 24, 2016 am 11:20 AM

只要在样式里面加一句去掉css去掉iPhone、iPad的默认按钮样式就可以了!~

input[type="button"], input[type="submit"], input[type="reset"] {

-webkit-appearance: none;

}

textarea {  -webkit-appearance: none;}   

如果还有圆角的问题,

.button{ border-radius: 0; } 

 

我们在写表单的时候会发现一些浏览器对表单赋予了默认的样式,如在Chorme浏览器下,文本框及下拉选择框当载入焦点时,都会出现发光的边框,并且在火狐及谷歌浏览器下,多行文本框textarea还可以自由拖拽拉大,另外还有在IE10下,当文本框输入内容后,在文本框的右侧会出现一个小叉叉,等等。不容置疑,这些效果是在用户体验上得到了提升,但有些时候我们并不需要这些默认的样式,那怎么办呢?下面我们就来分别看一下解决办法。

1、去除Chrome等浏览器文本框默认发光边框

 

 

 

input:focus, textarea:focus {

     outline :  none ;

}

去掉高光样式:

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

当然这样以来,当文本框载入焦点时,所有浏览器下的文本框的边框都不会有颜色上及样式上的变化了,但我们可以重新根据自己的需要设置一下,如:

 

 

 

 

input:focus,textarea:focus {

     outline :  none ;

     border :  1px  solid  #f60 ;

}

这样的话,当文本框载入焦点时,边框颜色就会变为橙色,给用户一个反馈。

2、去除IE10+浏览器文本框后面的小叉叉

只需下面一句就ok了

 

 

 

input::-ms-clear {

     display :  none ;

}

3、禁止多行文本框textarea拖拽

这样按下面添加属性多行文本框就不能拖拽放大缩小了:

 

 

 

textarea {

     resize:  none ;

}

在这里要提到一个属性resize,这个是CSS3属性,用于元素缩放,它可以取以下几个值:

none 默认值

both 允许水平方向及垂直方向缩放

horizontal 只允许水平方向缩放

vertical 只允许垂直方向缩放

不仅可以针对textarea元素,对大多数元素都适用,如div等,在这里不一一列举,但与textarea不同的是,对div使用时需要加上一句overflow: auto;,也就是这样才有效果:

 

 

 

 

div {

     resize:  both ;

     overflow :  auto ;

}

哦了,以上就是关于去除表单浏览器默认样式的一些内容。

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 Article Tags

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)

Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update? Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update? Mar 04, 2025 pm 12:32 PM

Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?

How do I use HTML5 form validation attributes to validate user input? How do I use HTML5 form validation attributes to validate user input? Mar 17, 2025 pm 12:27 PM

How do I use HTML5 form validation attributes to validate user input?

How to efficiently add stroke effects to PNG images on web pages? How to efficiently add stroke effects to PNG images on web pages? Mar 04, 2025 pm 02:39 PM

How to efficiently add stroke effects to PNG images on web pages?

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

What is the purpose of the <iframe> tag? What are the security considerations when using it?

What are the security implications of using iframes, and how can I mitigate them? What are the security implications of using iframes, and how can I mitigate them? Mar 18, 2025 pm 02:51 PM

What are the security implications of using iframes, and how can I mitigate them?

How do I use the HTML5 <meter> element to display numerical data within a range? How do I use the HTML5 <meter> element to display numerical data within a range? Mar 12, 2025 pm 04:08 PM

How do I use the HTML5 <meter> element to display numerical data within a range?

What are the best practices for cross-browser compatibility in HTML5? What are the best practices for cross-browser compatibility in HTML5? Mar 17, 2025 pm 12:20 PM

What are the best practices for cross-browser compatibility in HTML5?

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

What is the purpose of the <meter> element?

See all articles