由于标准页面布局不允许您调整绑定(bind)到文本字段的输入字段的宽度,因此我正在尝试创建一个 VisualForce 页面,但 apex:inputfield 组件没有宽度属性。我想我将不得不使用样式或 CSS 或其他东西,但我不知道如何。
我需要做什么来调整文本输入字段的宽度?
请使用 Web 界面(不是 Force.com IDE)提供说明。谢谢。
编辑
我最终使用了这样的嵌入式样式
<apex:inputfield value="{!Country__c.Full_Name__c}" style="width:400px"/>
最佳答案
您应该能够使用 css 执行此操作。几乎所有的 Visualforce 标签都有一个名为 styleClass 的属性,它是要使用的 css 类的名称,即:
<apex:inputText styleClass="myClass" ... />
变成:
<input type="text" class="myClass" ... />
因此,您可以使用它在页面顶部使用 CSS 指定宽度。这是使用标准联系人 Controller 的页面的完整示例(虽然没有很好的格式!):
<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>
这适用于
<apex:inputField>
同样,请注意不同字段类型可能发生的情况。要更具体地使用 css(仅限 CSS 3!),您可以这样做:input[type="text"].myClass = { width: 400px; }
关于salesforce - 如何控制 VisualForce 页面中顶点输入字段的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8920275/