跳到正文
Simon Willison 博客·· 6 小时前AI 评分40

Simon Willison 用 Claude Fable 5.2 生成 HTML select 样式展示页

Select Styling Specimens

AI 导读

Simon Willison 因不满 HTML select 下拉框在各浏览器默认样式不一、在 Chrome 中尤其难看,让 Claude Fable 5.2 生成了一个展示 select 各种可样式化方式的页面,计划在每个桌面和移动浏览器中截图。他实验后给出自己最喜欢的 select CSS 写法,并展示了该样式在三个浏览器中的效果。

正文 · 原文

Tool: Select Styling Specimens

I got frustrated at how HTML <select> boxes default to looking different in different browsers, and are (I think) quite ugly in Chrome:

The same select box in Chrome, Safari, and Firefox, Chrome is white with a black border. Safari is grey with no border. Firefox is gray with a black border. They are all slightly different sizes.

So I had Claude Fable 5.2 build me this page showing all of the ways they can be styled:

Build an HTML page that shows all of the ways a select box can be styled, I plan to take screenshots in every desktop and mobile browser

After some experimentation I've decided my favorite CSS for select boxes is this:

select {
  appearance: none;
  color: #1f2933;
  padding: 0.5em 2.25em 0.5em 0.75em;
  border: 1px solid #c4cbd3;
  border-radius: 6px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23667085' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 0.75em center / 0.75em;
}

Here's what that looks like in the three browsers:

Now the select box is the same in all three browsers - it has a rounded corner grey border and a grey downward facing arrow in each one.

Tags: tools, css, html

来源:Simon Willison 博客 · simonwillison.net