从
Chrome 的用户代理样式表为
没有人在工作。
当我在 webkit 的开发工具中检查该元素时,计算样式仍然将半径列为 5px。但如果我单击旁边的扩展箭头查看具体信息,它会显示:element.style - 0px。下面显示了我给出的 0px 外部 css 规范,以及 5px 的用户代理样式表规范。后两者都被划掉了,正如它们应该的那样。
有什么想法吗?
The user-agent stylesheet for Chrome gives a border-radius of 5px to all the corners of a <select>
element. I've tried getting rid of this by applying a radius of 0px through my external stylesheet, as well inline on the element itself; I've tried both border-radius:0px
and -webkit-border-radius:0px;
and I've tried the even more specific border-top-left-radius:0px
(along with it's -webkit equivalent).
None are working.
When I examine the element in webkit's developer tools, the Computed Style still lists the radius as 5px. But if I click the expander arrow next to it to see the specifics, it reads: element.style - 0px. And below that it shows the external css specification I gave of 0px, along with the user-agent stylesheet specification of 5px. And both of those latter two are crossed out, as they should be.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(15)
这对我有用(样式第一个外观而不是下拉列表):
http://jsfiddle.net/fMuPt/
This works for me (styles the first appearance not the dropdown list):
http://jsfiddle.net/fMuPt/
只是我的下拉图像解决方案
(inline svg)
我正在使用bootstrap,这就是我使用
select.form-control
的原因
您可以改用
select{
或select.your-custom-class{
。Just my solution with dropdown image
(inline svg)
I'm using bootstrap that's why I used
select.form-control
You can use
select{
orselect.your-custom-class{
instead.如果你想要方形边框并且仍然想要小扩展箭头,我推荐这个:
If you want square borders and still want the little expander arrow, I recommend this:
这里有一些很好的解决方案,但这个不需要 SVG,通过
outline
保留边框并将其设置为与按钮齐平。Some good solutions here but this one doesn't need SVG, preserves the border via
outline
and sets it flush on the button.虽然最上面的答案删除了边框,但它也删除了箭头,这使得用户将元素识别为选择的元素变得极其困难(如果不是不可能的话)。
我的解决方案是在选择后面粘贴一个白色 div (边框半径:0px)。将其位置设置为绝对,将其高度设置为选择的高度,然后就可以开始了!
While the top answer removes the border, it also removes the arrow which makes it extremely difficult if not impossible for the user to identify the element as a select.
My solution was to just stick a white div (with border-radius:0px) behind the select. Set its position to absolute, its height to the height of the select, and you should be good to go!
具有自定义右下拉箭头的解决方案,仅使用 css(无图像)
Solution with custom right drop-down arrow, uses only css (no images)
保持简单并避免弄乱箭头和其他此类功能的一种方法是将其放置在与选择标签具有相同背景颜色的 div 中。
One way to keep it simple and avoid messing with the arrows and other such features is just to house it in a div with the same background color as the select tag.
应避免消除箭头。保留下拉箭头的解决方案是首先从下拉列表中删除样式:
然后在 HTML 中的下拉列表之前直接创建 div:
并像这样设置 div 样式:
显示内联将阻止 div 转到新行,绝对位置将删除从页面的流程来看。最终结果是一个漂亮干净的下划线,您可以根据需要设置样式,并且下拉列表的行为仍然符合用户的预期。
Eliminating the arrows should be avoided. A solution that preserves the dropdown arrows is to first remove styles from the dropdown:
Then create div directly before the dropdown in your HTML:
And style the div like this:
Display inline will keep the div from going to a new line, position absolute removes it from the flow of the page. The end result is a nice clean underline you can style as you'd like, and your dropdown still behaves as the user would expect.
插入框阴影就可以解决问题。
演示
Inset box-shadow does the trick.
Demo
由于某种原因它实际上受到边框颜色的影响???当您使用标准颜色时,角会保持圆角,但如果您稍微更改颜色,圆角就会消失。
https://jsfiddle.net/hLg70o70/2/
For some reason it's actually affected by the color of the border??? When you use the standard color the corners stay rounded but if you change the color even slightly the rounding goes away.
https://jsfiddle.net/hLg70o70/2/
好吧,我得到了解决方案。希望它可以帮助你:)
well i got the solution. hope it may help you :)
以下是执行此操作的方法;
Following is the way to do it;
我使用了jordan314的解决方案,但后来我添加了“border-light”类来选择。如果你在css中定义了默认的border-light类,你可以直接使用它。它只是将边框定义为白色)。我将边框更改为方形/删除半径,并保留箭头。
这就是我所做的:
如果你没有预定义的 border-light,只需在你的 css 中添加:
I used jordan314's solution, but then I added "border-light" class to select. If you have default border-light class defined in css, you can directly use it. It just defines the border as white). I changed the border to square/remove the radius, and maintained the arrow.
Here is what I did:
if you don't have the predefined border-light, just add in your css:
火狐浏览器:18
firefox: 18
请将 CSS 设置为Try。
如果有效,
Set the CSS as
Try if it works.