How to Position Input Fields over an Image Using CSS

I am working on positioning input fields over an image to allow data entry directly onto the image itself.

https://i.sstatic.net/jW4iM.png Currently, I have a series of input fields (shown above) and three images with different squares on them. My goal is to align the input fields within the squares. Below is the corresponding HTML/CSS code I am using. This is my first web development project, so any assistance or suggestions would be greatly appreciated.

.allapottab {
  display: none;
  text-align: right;
  height: 850px;
}

.festekoptions {
  width: 20px;
}
<div style="text-align: center;" class="allapottab">Külsõ állapota:
  <br>
  <img src="https://dummyimage.com/600x150/000/fff" width="600" height="150">
  <img src="https://dummyimage.com/600x150/000/fff" width="600" height="150">
  <img src="https://dummyimage.com/600x150/000/fff" width="600" height="150">
  <br>
  /* Input fields go here */
  <br>
  <label for="seruleselony"><b>Sérülések/Előnyök:</b></label>
  <input type="text" placeholder="Sérülések / Előnyök" name="seruleselony" id="seruleselony" required><br>
</div>

Answer №1

Your current approach may not provide the best UI/UX experience across all devices.

To improve, consider separating the rendering of input boxes from the car image. The car image should focus solely on displaying the car, without any overlaid boxes. Using an svg for the image can ensure consistent quality on screens of different sizes.

Next, determine the anchor points for each input and save their positions. This allows you to render each input independently from the image based on the device type:

  • For large screens, position input boxes at anchor points using absolute positioning. This flexibility allows for custom alignment (left, center, right, top, bottom, middle) based on the point's location in the image and possibly the viewport.
  • For small screens, consider displaying a circular button that opens a modal for user input. Additionally, a table below the image could show all input data if boxes are too large to overlay the image.

Implementing these changes should lead to a better UI/UX solution. However, breaking down your question and seeking specific answers to individual challenges will be more manageable for a platform like StackOverflow.

Consider asking focused questions such as:

  • How can I create an svg with positions relative to its dimensions?
  • What's the best way to position an element at a fixed point based on its parent's size?
  • And so on...

Many of these queries have likely been addressed before, so be sure to research thoroughly before seeking assistance for your unique issue.

Answer №2

Consider utilizing the position:absolute; property for better layout control.

For more information on this topic, you can refer to:

https://www.example.com/how-to-overlay-divs-with-css

Enhance your design by converting the divs into buttons or incorporating buttons within the divs.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Difficulty establishing a connection between NodeJS and Google Drive API

I am currently facing a challenge in my NodeJS application where I'm attempting to set up a gallery page. Despite having all the necessary configurations and connections with Google Drive API, something seems amiss when accessing the /gallery route. T ...

"When using the Fetch API to make a POST request, the req.body is found to

When attempting to call the POST API using the fetch method and passing parameters in the body, I encountered an issue where req.body was undefined on the Node.js backend side. However, when I called the same POST API through Postman with parameters in the ...

What is the best way to add content in JavaScript?

Just diving into the world of JavaScript, HTML, and web development tools here. var labels = {{ labels|tojson|safe }}; After using console.log to check the content of labels with console.log(JSON.stringify(labels));, I got this output: [ {"id":"1", ...

How can I convert Double Quotes from (") to (&quot;) in TinyMce Editor?

While using TinyMce Editor, I have encountered a problem with double quotes breaking my code. In the HTML source of TinyMce, it displays " instead of &quot, causing issues in conversion. It seems that it is not converting " to " as it should, simi ...

Ajax call fails to trigger upon change

Currently, I am focusing on creating an HTML table with a form that contains a select element offering options for ALL and Biscuits. Initially, the table populates correctly upon loading. However, I am facing an issue when attempting to trigger an AJAX ca ...

Essential Guide to Binding Events with JQuery

Why is the handler for an event on an element triggering the wrong response? I was expecting the click event of Div1 to display a dialog stating 'div1', but it's showing 'div2' instead. I am new to this and trying to figure out wh ...

"The presence of the <textarea> element is causing disruptions to the

I'm currently attempting to insert infusionsoft contact form code into a CodeBlock within the Avada theme. However, I've encountered an issue with a textarea field in the form that contains the following code: <div class="infusion-field"> ...

AngularJS allows users to import a file and submit it after closing the popup

I can't figure out how to submit the file I'm importing after clicking OK on the system's file upload window. Here is what I have tried so far: <input type="file" id="file-input" style="display:none" /> <button class="btn pull-ri ...

Is my Laravel application experiencing caching issues preventing real-time updates?

As I dive into learning AngularJS, I've encountered a strange issue where changes made in my JS files don't always seem to take effect. Even after seeing the GET request to the file in the console, the content remains unchanged. I can delete all ...

What steps are involved in incorporating a machine learning algorithm from a Python file into a Django website?

I'm currently utilizing the random forest algorithm in Python to make predictions about college dropouts. The algorithm has been completed, and now I need to integrate the file into a website using Django. However, I am facing issues as the imported f ...

Retrieve the value of a selected element

I currently have an HTML select drop down that is populated by a JQuery get request. You can see this in action at this link. My goal is to access the specific piece of code for the selected value every time it changes. <small class="text-muted"> ...

Use CSS to manipulate the dimensions of an overlay

Looking for a way to ensure that the height of your overlay matches the height of your carousel, even on smaller screen sizes? The HTML code below demonstrates how to combine simple HTML with a Bootstrap carousel featuring three images, along with an overl ...

Is it feasible to exclusively apply Twitter Bootstraps .navbar-fix-to-top on mobile devices?

I am working on a website using Twitter Bootstrap 3 and I have implemented the following navbar: <div class="col-xs-12 col-md-10 col-md-offset-1"> <nav class="navbar navbar-inverse" role="navigation"> <div class="navbar-header"> ...

Issue with Codeigniter's AJAX functionality causing div reloading to not function as intended

I am currently facing an issue where I can display text directly from the database on a webpage. However, when I edit the text in the database, I want it to automatically reload and show the updated text without having to refresh the entire page. Unfortun ...

Steps for inserting a menu item into a Material UI Card

Below is an example I'm working with: https://codesandbox.io/s/material-ui-card-styling-example-lcup6?fontsize=14 I am trying to add additional menu options such as Edit and Delete to the three dots menu link, but so far I have not been successful. ...

Generate the entity and then transfer the data into an array

I am dealing with multi-level hierarchies that need to be displayed in a select list. Once the user selects values from the table column, they should be able to filter by clicking on the column. var name = ['Akansha', 'Navya']; var age ...

Is there a foolproof method to verify if a user truly has visibility of a div element?

When I search online, most solutions only consider the viewport and/or the first parent container that is scrollable when trying to determine if a div is visible. However, I am wondering if there is a foolproof method to check if a div is truly visible t ...

When implementing v-model on a v-dialog component, it causes the element within an array to

There is an array of apps with links, and a Dialog component that has v-model="dialog" to close it. However, after adding v-model to the v-dialog, the functionality of the apps is affected. The current app is passed as a prop to Dialog, but it always sends ...

"Encountering an unidentified custom element in Vue 2 while exploring Vue libraries

In my Vue project, I have integrated libraries like FusionCharts and VueProgressBar. However, I encountered an error in my console: Unknown custom element: <vue-progress-bar> - did you register the component correctly? For recursive components, make ...

What is the significance of using parentheses around a function in JavaScript?

Currently, I am developing an application using Java and JavaScript, and while reviewing some code today, I came across a segment that seemed confusing to me. var myVariable = (function(configObj){ var width = configObj.width; var height = config ...