How can you hide the arrow that is displayed by de

2019-01-31 11:47发布

I now its still early but I also know you guys are on top of it.

I want to use the HTML5 details element:

<details>
<summary>What's the HTML5 details element?</summary>
<p>The details element represents a disclosure widget from which the user can obtain additional information or controls.</p>
</details>

As of this writing, Chrome 12 beta is the only browser to actually give the details element functionality (clicking on summary toggles the details content). So to answer the following question you'll probably want to use that browser.

Do you know how you can hide the arrow that is displayed by default on a details element in Chrome?

It's a bit like the default styling of <input type="search" /> in Webkit (see http://css-tricks.com/webkit-html5-search-inputs/). You can change it but it's not that obvious.

EDIT

Tried the following CSS code with no success:

details,
details summary {
padding-left:0;
background-image:none;
-webkit-appearance:none;
}

There probably is a chance we will need to target it with some weird pseudo selector like details::-webkit-details-disclosure-widget or there's currently no way to change things at all.

Furthermore I found this in the specification:

The first container is expected to contain at least one line box, and that line box is expected to contain a disclosure widget (typically a triangle), horizontally positioned within the left padding of the details element. That widget is expected to allow the user to request that the details be shown or hidden.

4条回答
可以哭但决不认输i
2楼-- · 2019-01-31 12:19

I didn't plan to answer my own question but I have the solution.

Code

details summary::-webkit-details-marker {
  display:none;
}

Note that the disclosure widget will still be displayed if you don't provide a summary element, which is allowed by the spec.

查看更多
手持菜刀,她持情操
3楼-- · 2019-01-31 12:29

summary::-webkit-details-marker { font-size:0px }

查看更多
4楼-- · 2019-01-31 12:30

I find this works well enough.

::-webkit-details-marker { display:none; }

查看更多
We Are One
5楼-- · 2019-01-31 12:39

I'm not sure if this will work, given that my current computer will not run Chrome and I do not have access to the computer I normally use, but try adding this to your css file:

details > summary:first-of-type {
    list-style-type: none;
}

Do tell me if it works, I only saw it in a recommendation, not an official spec.

查看更多
登录 后发表回答