How to Style Select Lists with Padding in Safari and IE Despite W3 Specification?

Barbara Streisand
Release: 2024-10-24 08:51:02
Original
509 people have browsed it

How to Style Select Lists with Padding in Safari and IE Despite W3 Specification?

Styling Select Lists with Padding in Safari and IE

Despite the W3 specification not prohibiting the use of padding in select boxes, Webkit browsers such as Safari and Chrome do not support this feature. To achieve the desired effect, consider replacing the padding-left property with text-indent, ensuring to adjust the select box width accordingly.

Example:

In the following code snippet, the padding-left property is removed and replaced with text-indent:

<code class="html"><select id="sexID" name="user[sex]" 
        style="border:1px solid #C1272D;
               width:258px; // 243 + 15px
               text-indent:15px;
               height:25px;
               color:#808080;"></code>
Copy after login

By adding the same amount of text indentation as the padding would have occupied, the select box now has a left-aligned text field. This workaround effectively simulates the behavior of padding in Safari and IE, providing a consistent styling experience across different browsers.

The above is the detailed content of How to Style Select Lists with Padding in Safari and IE Despite W3 Specification?. For more information, please follow other related articles on the PHP Chinese website!

source:php
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template