This app takes an image, which is essential a background, or workspace. I need to add input text fields onto this workspace given specific coordinates (top, left, width, height). These coordinates would be relative to the image (top/left = 0/0). How would I position my fields/elements relative to the image?
<img id="background" ng-src="{{page.backgroundImage}}" />
<input type="text" ng-repeat="field in page.fields" ng-model="field.value"
ng-style="{position:'absolute',
left:field.left,
top:field.top,
width:field.width,
height:field.height}"/>
The code above works great for absolute positioning but it is not relative to the image.
<div style="position:relative">
<img id="background" ng-src="{{page.backgroundImage}}" class="course-image" />
<input type="text" ng-repeat="field in page.fields" ng-model="field.value"
style="position:absolute"
ng-style="{left:field.left,
top:field.top,
width:field.width,
height:field.height}" />
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With