1

Below is the simplest version of VF page where I want to increase the width of Case Owner input field:

<apex:page standardController="Case">
    <apex:form >
        <apex:inputField value="{!Case.Subject}" style="width:350px"/> 
        <apex:inputField value="{!Case.OwnerId}" style="width:350px"/> 
    </apex:form>
</apex:page>

I have tried adding the style , styleclass, wrapping the input field in a <div>. The other text fields are working fine problem is with only case owner field.

But the width is showing as per standard salesforce css.

Please advise if anyone knows how to achieve this.

1 Answer 1

4

For lookup fields, the styling will get placed in a <div> wrapper element and not directly on the input itself. What you will have to do is put a styleClass on your field, which will get placed on the <div>, and use the generated HTML structure to correctly target the input element.

For example, if you take this code:

<apex:form>
    <apex:inputField value="{!Case.OwnerId}" styleClass="test"/>
</apex:form>

The generated code will look like this:

enter image description here

You can then target the input with some CSS to achieve your desired result:

<style>
    .test input {width:350px}
</style>
1
  • @C0DEPirate happy to help. :) Commented Nov 27, 2017 at 14:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .