【发布时间】:2017-04-05 10:01:54
【问题描述】:
我有一个简单的HTML 页面,其中有 4 个buttons 和 4 个divs,如下所示 -
<!DOCTYPE html>
<html>
<head>
<style>
div.top {
position: relative;
left: 205px;
width: 200px;
height: 200px;
border: 3px solid #000000;
}
div.left {
position: relative;
top: 0px;
right: 0;
width: 200px;
height: 200px;
border: 3px solid #000000;
}
div.right {
position: relative;
bottom: 205px;
left: 410px;
width: 200px;
height: 200px;
border: 3px solid #000000;
}
div.bottom {
position: relative;
bottom: 205px;
left: 205px;
width: 200px;
height: 200px;
border: 3px solid #000000;
}
</style>
</head>
<div class="top"></div>
<div class="left"></div>
<div class="right"></div>
<div class="bottom"></div>
<button type="button">Image 1</button>
<button type="button">Image 2</button>
<button type="button">Image 3</button>
<button type="button">Image 4</button>
</body>
</html>
我希望用户能够在单击按钮时从文件浏览器中选择特定图像,并在相应的div 中显示相同的图像。例如。当用户点击Image 1 时,文件浏览器会要求他选择一张图片,该图片在被选中后会显示在特定的 div 中。我希望用户能够为所有 4 个 div 和按钮执行此操作。
一直坚持这个太久了,非常感谢任何帮助!
【问题讨论】:
-
这个代码在哪里?你已经尝试过什么?
-
我查看了如何允许用户上传图片,我看到的所有代码 sn-ps 都包括构建表单。我是 HTML 新手,不确定是否有必要。因此我发布了一个问题。 @丹·怀特
-
文件只是另一种输入类型。即使是唯一的字段,它仍然是一个表单。
标签: javascript html css file image-uploading