如果图像大小小于Container Div size,则上传图像并以平铺格式显示
Upload image and show it in tile format if image size smaller then Container Div Size
我正在创建一个网站。
我需要在其中创建一个页面。我需要实现这些功能:
-
用户可以上传图像。
-
上传后,他/她可以看到那张照片。
-
我有一个固定的区域,宽度为500px,用户可以在上传后看到他/她的照片。
-
如果用户上传了一个小尺寸的图像。该图像不会拉伸,它将使用平铺格式填充区域。
-
它就像我们的桌面背景。
请帮我一下。
For1.使用ajax文件上传控件(或)普通aspx文件上传控件添加多张照片2.使用图像控制3.将图像控件宽度设置为500px4.在图像控制中,它可以选择定位图像5.您可以根据需要调整其大小以显示
您可以使用类似..的javascript。。
width = 0;
while (width<500){ // 500 the max width
diva.innerHtml+='insert image' // code to append the image in the div
width+=insertimage.width // code to set the total width that has been used
}
你也可以根据身高来做*注意:-以上代码仅用于说明,您需要对其进行更改。这里我已经为你写了一个示例代码
<head>
<title></title>
<script language="javascript" type="text/javascript">
function Button1_onclick() {
var h = document.getElementById("Text1");
var im = document.getElementById("Text3");
var dimage = document.getElementById("div1");
dimage.setAttribute("style", "width:" + h.value);
width = 0;
dimage.innerHTML = " ";
while (width < h.value) {
dimage.innerHTML += "<img alt='"'"src = '"" + im.value + "'"/>";
width += 100;
}
}
</script>
<style type="text/css">
.style1
{
height: 23px;
}
</style>
<table style="width:100%;">
<tr>
<td>
Max Width</td>
<td>
<input id="Text1" type="text" value="600" /></td>
<td>
</td>
</tr>
<tr>
<td>
Max Height</td>
<td>
<input id="Text2" type="text" value="500" /></td>
<td>
</td>
</tr>
<tr>
<td>
Image Location</td>
<td>
<input id="Text3" type="text"
value="www.conflictprevention-ks.org/images/img.jpg" /></td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input id="Button1" type="button" value="Load Image" onclick="return Button1_onclick()" /></td>
<td>
</td>
</tr>
<tr>
<td colspan="2" class="style1">
<div id="div1">
</div>
</td>
<td class="style1">
</td>
</tr>
</table>
只需将代码保存为一个html文件,看看它是如何工作的。
相关文章:
- 非常大的图像显示渐进
- CSS Html使图像显示在单选按钮的选项上(单选按钮被CSS隐藏)
- JS照片库.使大图像显示和缩略图可单击
- 多个图像显示带有动态创建的画布的最后一个图像并分配给图像
- 当我在jquery/javascript中单击按钮时加载图像显示
- React图像显示
- 随机图像显示,无重复,使用Javascript
- 将跨度内容(图像url)转换为图像(显示)
- 随机图像显示不止一次
- 节点.js 使用 Multer 上传图像显示未定义
- 范围滑块,用于更改轨道上方对齐圆的直径并使对齐的图像显示在下方
- 使用图像显示和隐藏
- 使用 JavaScript 将文件夹中的图库图像显示到网页中
- 画布到图像显示为无图像(空白)
- 传单不会将本地图像显示为叠加
- 切换此元素时,如何使不同的图像显示,而不是文本
- 在页面加载时将图像显示为弹出窗口
- 如何在模糊浏览器主窗口时将图像显示为叠加层
- iOS在画布上绘制图像显示:无会导致内存泄漏
- JavaScript 图像显示不起作用