简体   繁体   中英

JSF selectOneRadio indentation

Is there anyway to indent a set of radio buttons? I want it to look like the following:

o Item 1
o Item 2
    o Item 2.1
    o Item 2.2
o Item 3

I tried just applying a style to it but it doesn't work.

<style>
    .indent {
        text-indent: 3em;
    }
</style>

<p class="indent">test</p>

<h:selectOneRadio layout="pageDirection" value="#{myBean}">
    <f:selectItem itemValue="1" itemLabel="Item 1" />
    <f:selectItem itemValue="2" itemLabel="Item 2" />   <!-- also okay if item 2 is not selectable and item 2.1 and 2.2 are -->
    <p class="indent">
        <f:selectItem itemValue="2.1"  itemLabel="Item 2.1" />
        <f:selectItem itemValue="2.2" itemLabel="Item 2.2" />
    </p>
    <f:selectItem itemValue="3" itemLabel="Item 3" />
</h:selectOneRadio>

Have you tried adding a margin instead of indent?

.myIndent { 
    margin-left: 3em; 
} 

Have a look at http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/ as well, they cover radio button styling.

I guess you want to display your radio buttons as a list. Add the layout attribute with pageDirection value to the <h:selectOneRadio /> tag component to achieve it:

<h:selectOneRadio layout="pageDirection" value="#{myBean}">
    <!-- your items go here... -->
</h:selectOneRadio>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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