문제

Since the standard Page Layouts don't allow you to adjust the width of an inputfield bound to a text field, I'm trying to create a VisualForce Page but there isn't a width attribute for the apex:inputfield component. I think I will have to use styles or CSS or something, but I don't know how.

What do I need to do to adjust the width of a text inputfield?

Please provide instructions using the web interface (not Force.com IDE). Thanks.

EDIT

I ended up using an embedded style like this

<apex:inputfield value="{!Country__c.Full_Name__c}" style="width:400px"/>
도움이 되었습니까?

해결책

You should be able to do this using css. Nearly all of the Visualforce tags have an attribute called styleClass, which is the name of a css class to use, i.e.:

<apex:inputText styleClass="myClass" ... />

Becomes:

<input type="text" class="myClass" ... />

So using this you could then specify the width using CSS at the top of the page. Here is a complete example for a page using the standard Contact controller (no nice formatting though!):

<apex:page standardController="Contact">
    <style type="text/css">
        .myClass { width: 400px; }
    </style>

    <apex:form >
        <apex:outputLabel for="firstName" value="First Name"/>
        <apex:inputText styleClass="myClass" id="firstName" value="{!Contact.FirstName}"/>
    </apex:form>
</apex:page>

This works for <apex:inputField> as well, though be wary of what may happen with different field types. To be more specific with the css (CSS 3 only!) you could do this:

input[type="text"].myClass = { width: 400px; }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top