图像作为可拖动的输入元素?
嵌入图像中的输入元素
在网络浏览器中
- 我希望
允许图像嵌入输入元素。
允许在容器内拖动这些图像
以制作这些图像具有足够的自我意识,当彼此靠近时,它们“对齐”在一起
示例:屏幕转储/视频
这里有一个屏幕转储,说明了我想要的类型: https://i.sstatic.net /j5oPj.jpg 。
为了更好地说明这一点,这里有一个视频(打开声音):http://www.screencast.com/ t/4BaLMzHK 。
我们可以这样做吗?
有哪些方法可以将图像“包裹”在 HTML/JS 中的输入元素周围?
(我不想使用:Flash;Java 或 Silverlight,但如果这是唯一的方法,我对此持开放态度)。
Input Elements embedded in Images
Within a Web Browser I want
to allow images to have an input element embedded within them.
to allow those images to be dragged around within a container
to make those images sufficiently self-aware that when close to each other they 'snapped' together
Examples : Screen Dump/Video
There's a screen dump here which illustrates the type of thing I'd like : https://i.sstatic.net/j5oPj.jpg .
To illustrate it better there's a video here (turn your sound on) : http://www.screencast.com/t/4BaLMzHK .
Can we do this ?
What are ways you could "wrap" an image around a input element in HTML/JS ?
(I would prefer not to use: Flash; Java or Silverlight but I'm open to that if that's the only way it can be done).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的 - 这不会是一个完整的、端到端的答案,但它应该为您提供构建块。
对于初学者来说,您不需要闪存或任何其他第三方东西。 HTML、CSS 和 Javascript 将满足您所需的一切。
好的,让我们看看“具有嵌入输入的图像”要求。您所描述的实际上只是表单输入周围元素的特定视觉样式。 HTML 有一个特定的元素用于此目的 -
我会使用这样的东西:
每个字段集都将成为一个可拖动的“模块”。样式应该足够简单 - 类似于:
使用附加类将允许您改变所使用的模块类型:
就我个人而言,我会尝试在没有图像的情况下完成它 - 使用标准背景颜色,加上 CSS3 边框半径、阴影和渐变效果将允许您在有能力的浏览器中获得非常漂亮的“拼图”类型的视觉样式,并且速度更快且更容易维护,因为当您想要重新调整大小时,您不需要重新创建图像。模块。您可能需要添加一些“标记”元素(只是
或
)标记“捕捉”点。
是的 - 这样您的 HTML 和 CSS 就基本完成了。接下来,您需要拖动和捕捉。我会在这里选择 jQueryUI。它的设置过程最简单,并且应该可以在多种浏览器中运行。
查看此演示:http://jqueryui.com/demos/draggable/#snap-to< /a>
所以,你的清单将是(按顺序)
我希望这有帮助!这是您尝试在此处构建的相当复杂的 UI 部分 - 希望这可以将其分解为可管理的块。祝你好运!
OK - this isn't going to be a complete, end-to-end answer, but it should give you the building blocks.
For starters, you won't need flash, or any other third party stuff. HTML, CSS and Javascript will do everything you need.
OK, let's look at the 'images with embedded inputs' requirement. What you're describing is really just a particular visual style for an element surrounding a form input. HTML has a specific element for this - the
<fieldset>
. Fieldsets are block elements, and can be given a background image (that sets the image you want), width, height, etc.I'd use something like this:
Each one of those fieldsets will become a draggable 'module'. The styling should be simple enough - something like:
Using an additional class will allow you to vary the types of modules you use:
Personally, I would try to do it without images - using standard background colors, plus CSS3 border-radius, shadows and gradient effects would allow you to get a very nice 'puzzle piece' type of visual style in capable browsers, and be much faster and easier to maintain, since you wouldn't need to re-create images when you want to re-size a module. You might need to add a little 'marker' element (just a
<span class="jigsawMale">
or<span class="jigsawFemale">
) to mark the 'snap' points.Right - so that's your HTML and CSS mostly done. Next, you need dragging and snapping. I'd go for jQueryUI here. It's the least painful to set up, and should work in a good variety of browsers.
Check this demo out: http://jqueryui.com/demos/draggable/#snap-to
So, your checklist will be (in order)
I hope that helps! It's a fairly complex piece of UI you're trying to build here - hopefully this breaks it down into manageable chunks. Good luck!