简体   繁体   English

如何在控件上添加5像素的额外边框?

[英]How can I add an extra border of 5 pixels on my controls?

I would like to add an extra border (thick) on my controls like here: http://tickspot.com/screenshots/ 我想在控件上添加一个额外的边框(粗线),例如: http : //tickspot.com/screenshots/

As we see in this link, the combos list and textbox have a blue tick border. 正如我们在此链接中看到的那样,组合列表和文本框都有一个蓝色的勾号边框。

How can I achieve this without too much effort? 我怎么能不花太多力气做到这一点?

Thank you. 谢谢。

You may nest your elements and give the outer element the border and the padding. 您可以嵌套您的元素,并为外部元素提供边框和填充。 here you'll get an impression: http://jsfiddle.net/jy92c/1/ 在这里您会得到印象: http : //jsfiddle.net/jy92c/1/

Not all form elements properly support css styling . 并非所有表单元素都正确支持css样式 You could probably find some styles that work across the board, but it might take some work. 您可能会找到一些可以全面使用的样式,但是可能需要一些工作。

The easier option to get consistency is to wrap your controls in a <span class='control'></span> The downside to this method is that you have to add extra markup. 获得一致性的更简单方法是将控件包装在<span class='control'></span> 。此方法的缺点是必须添加额外的标记。 You could give all the elements on your page class='addBorder' or something similar and then use JavaScript to find them and wrap them. 您可以将页面上的所有元素都class='addBorder'或类似的元素,然后使用JavaScript进行查找和包装。 That'd be a very unobtrusive method. 那将是一个非常吸引人的方法。 Comment if you need help on implementing this and I'd be happy to help. 评论您是否需要帮助以实施此方法,我们很乐意为您提供帮助。

A CSS only solution might be to use both border and outline styles : http://jsfiddle.net/RyJzC/ 仅CSS的解决方案可能是同时使用borderoutline样式: http : //jsfiddle.net/RyJzC/

(But remember outline is used to give an indication that an element has focus so make sure you take this behaviour into account if you do style outline ) (但是,请记住outline是用来给的指示,元素具有焦点所以一定要确保,如果你做的风格,你采取这种行为考虑在内outline

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM