What is the method for including a text field within an SVG?

I am new to working with SVG files and I have a question about placing a text field over an SVG file. Is it possible to add a text field within the SVG file itself? Currently, I am using the SVG file as an <img> in my HTML code. Can anyone guide me on how to achieve this? Here is the CSS code snippet:

  input[type="text"] {
  background-color: white;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-size: 115%;
 max-width:300%;
    float:right;
     width:40%;
    min-height:6.45%;

    position:absolute;
    left:2.68%;
    top:70%;
}

#textbox{
max-width:300%;
    float:right;
     width:20%;
    min-height:6.45%;

    position:absolute;
    left:1.70%;
    top:70%;
    z-index:1;

}

And here is the relevant part of my HTML file:

 <html>
    <head>
    </head>
    <body>
<div id="textbox">
    <input type="text"/>
    </div>
    <img src="samp.svg"/>
    </body>
    </html>

If anyone has experience with adding text fields over SVG files, your help would be greatly appreciated!

Answer №1

Combine the two elements within a wrapping container and then you have the option to position it absolutely in relation to its parent element. Adjust the dimensions and positioning values as per your requirements.

.input-svg {
  position: relative;
}
input[type="text"] {
  background-color: white;
  border: 1px solid rgba(0, 0, 0, 0.15);
  font-size: 115%;
  height: 5%;
  outline: medium none;
  padding: 0;
  left: 27.5px;
  position: absolute;
  top: 50%;
  width: 200px;
  z-index: 1;
}
<div class="input-svg">
  <input type="text">
  <img src="http://svgporn.com/logos/angular-icon.svg" />
</div>

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

Using jQuery to retrieve the domain extension from a URL

Seeking assistance with extracting domain extensions from various URLs using jQuery. Uncertain how to account for all possible scenarios. Here are the parts of the URL that need to be extracted: https://www.amazon.**com**/dp/067144901X https://www.amazon. ...

What is the best way to anchor an image to the bottom right corner while also adjusting its position as

Hey there! I have a challenge where I want to anchor an image at the bottom right corner of a webpage. Initially, it works perfectly using this CSS: .logo img{ position: absolute; bottom: 0; right: 0; } However, when I resize the window, the ...

Modify website's icon and position images gallery in the center using c#

I am currently developing a website using asp.net and c#. In my project, I have a gallery of images that I am struggling to center on the page. Here is what the gallery looks like: Gallery of images What I would like to achieve is something similar to thi ...

Linking multiple font files of the identical typeface to their respective CSS styles

I recently purchased the Didot font from myfonts.com, which includes different styles such as regular, bold, italics, and bold italics (each in separate files). While using WordPress, I noticed that when my users write articles with bold and italic text, ...

Toggle multiple buttons based on the data fetched in the created() lifecycle hook

I have several toggle buttons that should be selected based on the values present in the response obtained through the created() method. <li> <input v-on:click="toggleCheckbox($event)" ...

What is the best way to design a multi-submit form without the need for page refreshing?

I am interested in creating a form with multiple questions where users can click "next" for each question without the page reloading. For instance Click on "Begin" On this page, there is no reload when choosing a radio option and clicking "next". How ca ...

The initial responsive card doesn't show up on mobile devices until the screen is tapped

Check out this page: and view the source code. The first card doesn't appear until I scroll or tap on the screen, unlike the original codepen (https://codepen.io/Katiae/pen/zwjmbW) which works flawlessly. Any ideas for a solution? The only modificati ...

What is the best way to selectively add multiple classes to a single Material UI classes attribute based on certain conditions?

I am trying to use the Material UI Drawer and wish to add a class named "paperStyle" to the classes prop with the rule name "paper" and then, under certain conditions, apply an additional class called "specialPaperStyle" for specific users. However, I have ...

What is the best way to define the location of a button's on-click event using jQuery?

I'm having an issue with my website. It's a Wordpress site using the Contact Form 7 plugin. On the homepage, there is a button labeled "Get a quote" that I want to link to google.com when clicked. I tried using jQuery but it's not working pr ...

Stop unwanted overrides of CSS3 blinking background colors

I am facing an issue with a programmatically created table that has n rows. To distinguish between odd and even rows, I programatically add classes to them. Some of these rows have "special" content that needs to be highlighted. Currently, I am accomplishi ...

When placed within a <li> element, the <a> tag will not create a hyperlink to a page, but it will

I have encountered an issue with my anchor links. All of them are working properly except for the one in the second ul with an href="page1". Interestingly, the link shows the correct destination at the bottom left of my screen and works when I right-click ...

Dynamic CSS background images with Nuxt.js: a guide

Currently working with Nuxt.js and have developed a unique custom component. The component contains CSS that applies a background image using styling. However, the code I've implemented is resulting in an error message when attempting to run it. The ...

Unable to load nested iframe

When working with an HTML document, I tried to add an iframe in the body without any cross-origin restrictions (same URL). However, when I tried to do the same thing within the appended iframe, although the nested iframe element was successfully added to ...

How come the name of the file is not showing up in the file input after picking a file?

I am having an issue with some html/css that uses bootstrap for file selection. Despite selecting a file, the name of the file doesn't show up in Firefox or Chrome on Mac. <div class="custom-file"> <input type="file" class="custom-file-in ...

Switching the navbar state from a regular mode to a collapsed mode can be done manually

I need help with my navbar design: <nav class="navbar fixed-top navbar-expand-sm navbar-light"> <div class="container-fluid"> <button class="navbar-toggler" type="button" data-bs-toggle=&q ...

What is the best way to send an authorized request to a Django view from an external HTML page using AJAX

In django version 1.10, I have created register.html, login.html, and home.html pages for my application. These HTML pages are hosted on separate application servers. Utilizing a Custom User Model, I am able to successfully register users and store their ...

What is the process for transmitting data in JSON format generated by Python to JavaScript?

Utilizing Python libraries cherrypy and Jinja, my web pages are being served by two Python files: Main.py (responsible for handling web pages) and search.py (containing server-side functions). I have implemented a dynamic dropdown list using JavaScript w ...

Is there a way for me to prioritize the sidebar over the main content on the page

My theme is efficient and visually appealing, but there's one issue with the mobile layout - it displays the sidebar after the content. How can I rearrange this in my theme so that the sidebar appears before the content? Thanks for your help! ...

The headline is being improperly rendered inside a black box on Firefox

A while back, I inquired about creating a black box with padding around a two-line headline. The solution worked well, except for older versions of Internet Explorer. However, in Firefox, there are occasional issues with the display looking jagged. This oc ...

JavaScript Function that Automatically Redirects User or Updates Text upon Clicking "Submit" Button

Looking to create JavaScript functionality that directs users back to the homepage after submitting their name and email. The process should follow these steps: 1.) User clicks "Request a Brochure..." https://i.sstatic.net/KqH2G.jpg 2.) A window opens in ...