Home > Web Front-end > CSS Tutorial > How Can I Style a Select Box with ::after in WebKit?

How Can I Style a Select Box with ::after in WebKit?

DDD
Release: 2024-11-25 13:42:11
Original
436 people have browsed it

How Can I Style a Select Box with ::after in WebKit?

Stylish elements in WebKit presents a unique challenge. Developers often attempt to enhance their appearance using CSS pseudo-elements, such as ::after. However, in certain scenarios, encountering issues becomes inevitable. Let us delve into a specific query that highlights this conundrum.

The Query: Styling a box with two distinct parts, without relying on images. The HTML is straightforward:

<select name="">
  <option value="">Test</option>
</select>
Copy after login

Now, let's introduce some CSS:

select {
  -webkit-appearance: none;
  background: black;
  border: none;
  border-radius: 0;
  color: white;
}

select::after {
  content: " ";
  display: inline-block;
  width: 24px;
  height: 24px;
  background: blue;
}
Copy after login

Unfortunately, the styling does not render as expected. Perplexed by the failure, the developer seeks guidance in the W3C specifications but comes up empty-handed.

The Answer: A Potential Limitation

Based on observation, it seems that adding ::after to style elements may seem simple in most browsers, WebKit presents a unique obstacle when it comes to using ::after. For the moment, alternative approaches may be necessary to achieve desired effects.

The above is the detailed content of How Can I Style a Select Box with ::after in WebKit?. For more information, please follow other related articles on the PHP Chinese website!

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