實現圖片分割---產生多個div分割圖片 使用for和二維數組來設定背景定位,div二維數組
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#box{width:832px;height:832px;margin:0 auto;border:1px solid red;}
.col{width:50px;height:50px;border:1px solid #fff;float:left;background:url(xin.jpg) no-repeat;}
</style>
</head>
<body>
<div id="box"></div>
</body>
</html>
<script type="text/javascript">
var box=document.getElementById("box");
var rowDiv=[];
var tArray=new Array();
for(var i=0;i<16;i++)
{
tArray[i]=new Array();
for(var j=0;j<16;j++)
{
rowDiv[j]=document.createElement("div");
box.appendChild(rowDiv[j]);
rowDiv[j].className="col";
tArray[i][j]=rowDiv[j];
var l=-(j*50)+"px";
var T=-(i*50)+"px";
tArray[i][j].style.backgroundPositionX=l;
tArray[i][j].style.backgroundPositionY=T;
}
}
</script>
html中怎實現下面的這種分割線效果?(圖)解答
這個應該不是分割線。
如果是兩條分割線,設定屬性display:inline-block.
例子:
<div style=" width:100%; text-align:center"> //設定置中
<hr style=" width:20%; display:inline-block" /> 中間插入的文字 <hr style=" width:20%; display:inline-block" />
</div>
利用matlab將一張圖片分割成10×10的小圖片,程式
樓上的太想當然了
clc
clear
src_path='c:\1.jpg'; %原始圖片路徑
dst_path='c:\pic_div\';%分割圖片後儲存路徑
mkdir(dst_path);%路徑不存在則產生
A = imread(src_path); %讀入原始圖片
[m,n,l] = size(A); %獲得尺寸
for i = 1:10
for j = 1:10
m_start=1+(i-1)*fix(m/10);
m_end=i*fix(m/10);
n_start=1+(j-1)*fix(n/10);
n_end=j*fix(n/10);
AA=A(m_start:m_end,n_start:n_end,:); %將每塊讀入矩陣
imwrite(AA,[dst_path num2str(i) '-' num2str(j) '.jpg'],'jpg'); %儲存每塊圖片
end
end
如上代碼已經過驗證