I have a visualforce page that I am embedding directly inside the standard page layout for the Products object. I am trying to make it look and feel like a native widget. I followed the suggestion here to do that: https://salesforce.stackexchange.com/a/45610/49567
However, I'm having a bit of an issue: The width of the columns in the widget is not consistent with that of the standard field labels/values on the page.
If I resize the browser window, they become misaligned. Here is some screenshots illustrating this undesirable behavior ("product image" is the custom VF widget, "product description" is a standard field in the native layout):
Alignment when browser is sized just right (how I want it to look):
Alignment when browser width is reduced slightly (not good)
Alignment when browser width is reduced even more (even worse)
Here is my Visualforce code (irrelevant parts truncated for brevity):
<apex:page standardController="Product2" extensions="ProductPhotosExtension">
<apex:form id="photoUploaderForm">
<apex:pageBlock mode="maindetail">
<apex:pageBlockSection columns="2">
<apex:pageBlockSectionItem labelStyle="display:none;" dataStyle="display:none;">
<apex:outputText> </apex:outputText>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel value="Product Image" for="fileImageId"/>
<apex:inputFile id="fileImageId" value="{!fileBody}"
filename="{!fileName}" onchange="uploadFile(event);"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:actionFunction name="callUploadMethod" action="{!upload}"/>
</apex:form>
</apex:page>
NOTE: I have the VF widget set to 100% width and 50 pixel height
columns="1"
since you're not actually using a second column.<apex:pageBlock mode="maindetail">
is basically meant to behave like the standard detail page. It's designed for a full page rather than an embedded widget, so it scales as the width of the widget is the width of the entire page