简体   繁体   English

如何设置ah:selectBooleanCheckbox的边框样式?

[英]How to style the border of a h:selectBooleanCheckbox?

How can I give the <h:selectBooleanCheckbox> a red border? 如何给<h:selectBooleanCheckbox>红色边框?

I tried it as follows, but the border doesn't appear at all. 我按如下方法尝试过,但是边框根本没有出现。

<h:selectBooleanCheckbox style="border: 1px solid red;" />

试试这个,

<h:selectBooleanCheckbox id="deleSub" style="border-color:red;" value="#mobeeCustomerHome.deleteSubscription}" />

The JSF <h:selectBooleanCheckbox> generates a HTML <input type="checkbox"> element. JSF <h:selectBooleanCheckbox>生成一个HTML <input type="checkbox">元素。 The style of the HTML <input type="checkbox"> element is very strictly controlled by the specific webbrowser used by the client. HTML <input type="checkbox">元素的样式非常严格地由客户端使用的特定Web浏览器控制。

Using border works in Internet Explorer only and even then the appearance is ugly. 使用border仅在Internet Explorer中有效,即使这样外观也很难看。 There's some good padding between the box and the border. 框和边框之间有一些良好的填充。 To get it to appear the way you want in other browsers you should be using outline instead. 要使其在其他浏览器中以您想要的方式显示,您应该改用outline

<h:selectBooleanCheckbox style="outline: 1px solid red" />

Note that this does in turn not work in IE! 请注意,这反过来在IE中不起作用! You'd likely want to specify the both CSS properties if you want to have a red border across all browsers. 如果要在所有浏览器中使用红色边框,则可能需要同时指定两个 CSS属性。

<h:selectBooleanCheckbox style="border: 1px solid red; outline: 1px solid red" />

Please note that this is completely unrelated to JSF. 请注意,这与JSF完全无关。 It's a pure HTML/CSS matter. 这是纯HTML / CSS问题。 JSF is merely a HTML code generator. JSF仅仅是HTML代码生成器。 The problem ultimately boils down to the styleability of a HTML <input type="checkbox"> element. 问题最终归结为HTML <input type="checkbox">元素的可样式性。

A completely different alternative is to go for a 3rd party JSF component library which allows more fine grained control over the UI, such as PrimeFaces . 完全不同的选择是使用第三方JSF组件库,该库允许对UI进行更细粒度的控制,例如PrimeFaces See also the <p:selectBooleanCheckbox> showcase . 另请参见<p:selectBooleanCheckbox>展示柜 It's using jQuery UI (with CSS themeroller !) under the covers. 幕后使用jQuery UI (带有CSS themeroller !)。

This has more the to due with the HTML checkbox itself rather than the JSF tag. 这更多是由于HTML复选框本身而不是JSF标记。

See post: How to change checkbox's border style in CSS? 请参阅文章: 如何在CSS中更改复选框的边框样式?

You could try: 您可以尝试:

outline: 1px solid red;
-moz-appearance: none;

This gets part of the way I think your looking for in FF it does nothing in IE8 (border does nothing in IE8 either). 这是我认为您在FF中寻找它的一部分,它在IE8中没有任何作用(边界在IE8中也没有作用)。 I haven't tested any other browsers. 我还没有测试其他浏览器。

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

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