GVKun编程网logo

js实现的简单图片浮动效果完整实例(js实现图片滑动)

11

这篇文章主要围绕js实现的简单图片浮动效果完整实例和js实现图片滑动展开,旨在为您提供一份详细的参考资料。我们将全面介绍js实现的简单图片浮动效果完整实例的优缺点,解答js实现图片滑动的相关问题,同时

这篇文章主要围绕js实现的简单图片浮动效果完整实例js实现图片滑动展开,旨在为您提供一份详细的参考资料。我们将全面介绍js实现的简单图片浮动效果完整实例的优缺点,解答js实现图片滑动的相关问题,同时也会为您带来C#实现3D效果完整实例、HTML+JS实现的简单图片轮播、jQuery实现动态表单验证时文本框抖动效果完整实例、jquery实现的回旋滚动效果完整实例【附demo源码下载】的实用方法。

本文目录一览:

js实现的简单图片浮动效果完整实例(js实现图片滑动)

js实现的简单图片浮动效果完整实例(js实现图片滑动)

本文实例讲述了js实现的简单图片浮动效果。分享给大家供大家参考,具体如下:

利用window对象,实现一个图片的浮动效果

1、现有一个广告div,就是我们要控制的,它的起始点(0,0)

2、设定横向和纵向的速度

3、控制广告div移动

1)广告div是否达到边界 2)如果到达边界后,我们设置速度反向移动

rush:js;"> 无<a href="https://www.jb51.cc/tag/biaoti/" target="_blank">标题</a>文档

更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》及《用法总结》

希望本文所述对大家JavaScript程序设计有所帮助。

总结

以上是小编为你收集整理的js实现的简单图片浮动效果完整实例全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

C#实现3D效果完整实例

C#实现3D效果完整实例

本文实例讲述了C#实现3D效果的方法。分享给大家供大家参考,具体如下:

一、新建一类文件

private static double[] addVector(double[] a,double[] b)
{
    return new double[] { a[0] + b[0],a[1] + b[1],a[2] + b[2] };
}
private static double[] scalarProduct(double[] vector,double scalar)
{
    return new double[] { vector[0] * scalar,vector[1] * scalar,vector[2] * scalar };
}
private static double dotProduct(double[] a,double[] b)
{
    return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}
private static double norm(double[] vector)
{
    return Math.Sqrt(dotProduct(vector,vector));
}
private static double[] normalize(double[] vector)
{
    return scalarProduct(vector,1.0 / norm(vector));
}
private static double[] crossproduct(double[] a,double[] b)
{
    return new double[] 
        { 
          (a[1] * b[2] - a[2] * b[1]),(a[2] * b[0] - a[0] * b[2]),(a[0] * b[1] - a[1] * b[0]) 
        };
}
private static double[] vectorProductIndexed(double[] v,double[] m,int i)
{
    return new double[]
        {
          v[i + 0] * m[0] + v[i + 1] * m[4] + v[i + 2] * m[8] + v[i + 3] * m[12],v[i + 0] * m[1] + v[i + 1] * m[5] + v[i + 2] * m[9] + v[i + 3] * m[13],v[i + 0] * m[2] + v[i + 1] * m[6] + v[i + 2] * m[10]+ v[i + 3] * m[14],v[i + 0] * m[3] + v[i + 1] * m[7] + v[i + 2] * m[11]+ v[i + 3] * m[15]
        };
}
private static double[] vectorProduct(double[] v,double[] m)
{
    return vectorProductIndexed(v,m,0);
}
private static double[] matrixProduct(double[] a,double[] b)
{
    double[] o1 = vectorProductIndexed(a,b,0);
    double[] o2 = vectorProductIndexed(a,4);
    double[] o3 = vectorProductIndexed(a,8);
    double[] o4 = vectorProductIndexed(a,12);
    return new double[]
        {
          o1[0],o1[1],o1[2],o1[3],o2[0],o2[1],o2[2],o2[3],o3[0],o3[1],o3[2],o3[3],o4[0],o4[1],o4[2],o4[3]
        };
}
private static double[] cameraTransform(double[] C,double[] A)
{
    double[] w = normalize(addVector(C,scalarProduct(A,-1)));
    double[] y = new double[] { 0,1,0 };
    double[] u = normalize(crossproduct(y,w));
    double[] v = crossproduct(w,u);
    double[] t = scalarProduct(C,-1);
    return new double[]
        {
          u[0],v[0],w[0],u[1],v[1],w[1],u[2],v[2],w[2],dotProduct(u,t),dotProduct(v,dotProduct(w,1
        };
}
private static double[] viewingTransform(double fov,double n,double f)
{
    fov *= (Math.PI / 180);
    double cot = 1.0 / Math.Tan(fov / 2);
    return new double[] { cot,cot,(f + n) / (f - n),-1,2 * f * n / (f - n),0 };
}
public static Image Generate(string captchaText)
{
    int fontsize = 24;
    Font font = new Font("Arial",fontsize);
    Sizef sizef;
    using (Graphics g = Graphics.FromImage(new Bitmap(1,1)))
    {
      sizef = g.MeasureString(captchaText,font,StringFormat.GenericDefault);
    }
    int image2d_x = (int)sizef.Width;
    int image2d_y = (int)(fontsize * 1.3);
    Bitmap image2d = new Bitmap(image2d_x,image2d_y);
    Color black = Color.Black;
    Color white = Color.White;
    using (Graphics g = Graphics.FromImage(image2d))
    {
      g.Clear(black);
      g.DrawString(captchaText,Brushes.White,0);
    }
    Random rnd = new Random();
    double[] T = cameraTransform(new double[] { rnd.Next(-90,90),-200,rnd.Next(150,250) },new double[] { 0,0 });
    T = matrixProduct(T,viewingTransform(60,300,3000));
    double[][] coord = new double[image2d_x * image2d_y][];
    int count = 0;
    for (int y = 0; y < image2d_y; y += 2)
    {
      for (int x = 0; x < image2d_x; x++)
      {
        int xc = x - image2d_x / 2;
        int zc = y - image2d_y / 2;
        double yc = -(double)(image2d.GetPixel(x,y).ToArgb() & 0xff) / 256 * 4;
        double[] xyz = new double[] { xc,yc,zc,1 };
        xyz = vectorProduct(xyz,T);
        coord[count] = xyz;
        count++;
      }
    }
    int image3d_x = 256;
    int image3d_y = image3d_x * 9 / 16;
    Bitmap image3d = new Bitmap(image3d_x,image3d_y);
    Color fgcolor = Color.White;
    Color bgcolor = Color.Black;
    using (Graphics g = Graphics.FromImage(image3d))
    {
      g.Clear(bgcolor);
      count = 0;
      double scale = 1.75 - (double)image2d_x / 400;
      for (int y = 0; y < image2d_y; y += 2)
      {
        for (int x = 0; x < image2d_x; x++)
        {
          if (x > 0)
          {
            double x0 = coord[count - 1][0] * scale + image3d_x / 2;
            double y0 = coord[count - 1][1] * scale + image3d_y / 2;
            double x1 = coord[count][0] * scale + image3d_x / 2;
            double y1 = coord[count][1] * scale + image3d_y / 2;
            g.DrawLine(new Pen(fgcolor),(float)x0,(float)y0,(float)x1,(float)y1);
          }
          count++;
        }
      }
    }
    return image3d;
}

注意引用命名空间:

using System.Drawing;

二、页面调用

Response.ContentType = "image/pjpeg";
Captcha.Generate("我就是3D内容").Save(Response.OutputStream,System.Drawing.Imaging.ImageFormat.Jpeg);

更多关于C#相关内容感兴趣的读者可查看本站专题:《C#常见控件用法教程》、《WinForm控件用法总结》、《C#数据结构与算法教程》、《C#面向对象程序设计入门教程》及《C#程序设计之线程使用技巧总结》

希望本文所述对大家C#程序设计有所帮助。

HTML+JS实现的简单图片轮播

HTML+JS实现的简单图片轮播

实现方法众多,这里我的思路为:

  容器(这里我使用table)中的初始图片为某一张,JS的timer(理解为全局)的timerout()事件中改变容器中<img>的src属性值,也即图片路径,从而达到每若干秒更换一次图片。

简单实现:

一、容器及<img src>初始值

<table>
  <tr>
     <td id="main_info_jpeg" onclick="fun1()"> //此处onclick事件也能切换图片
       <img id=''imginfo'' src="./image/test01.jpg"title="01">
     </td>
   </tr>
</table>

二、JS轮换函数及timer

<script type="text/javascript">
	//以下脚本实现三张主图的切换
	function fun1(){
		var now_jpeg = document.getElementById("imginfo").getAttribute("src");
		//document.writeln(now_jpeg);
		switch(now_jpeg)
		{
			case ''./image/test01.jpg'':
				document.getElementById(''imginfo'').setAttribute("src",''./image/test02.jpg'');
				break;	
			case ''./image/test02.jpg'':
				document.getElementById(''imginfo'').setAttribute("src",''./image/test03.jpg'');
				break;	
			case ''./image/test03.jpg'':
				document.getElementById(''imginfo'').setAttribute("src",''./image/test01.jpg'');
				break;			
			default:
				document.writeln("未获取src");
				break;	
		}
	}
	self.setInterval(''fun1()'',3000); //作为全局变量理解,事件为:timerout(),事件处理函数为:fun1().
</script>  

三、实现效果

  1,鼠标点击图片,图片切换

  2,不做任何操作,每3秒图片自动切换一次

jQuery实现动态表单验证时文本框抖动效果完整实例

jQuery实现动态表单验证时文本框抖动效果完整实例

本文实例讲述了jQuery实现动态表单验证时文本框抖动效果。分享给大家供大家参考。具体如下:

这里使用jQuery实现的动态表单验证特效,当用户输入错误或没有输入的时候点击提交按钮,有问题的输入框会抖动几下,以提示用户此项有问题,文本框抖动功能都有意思,这个表单比较典型,想实现jquery Ajax表单功能的可以参考。

运行效果截图如下:

在线演示地址如下:

http://demo.jb51.net/js/2015/jquery-table-txt-check-shake-style-codes/

具体代码如下:

<!DOCTYPE html>
<head>
<title>jQuery动态表单验证效果</title>
<style type="text/css">
body
{
 font-family:Arial,Sans-Serif;
 font-size:0.85em;
}
img 
{
 border:none;
}
ul,ul li
{
 list-style-type: none;
 margin: 0;
 padding: 0;
}
ul li.first
{
 border-top: 1px solid #DFDFDF;
}
ul li.last
{
 border: none;
}
ul p
{
 float: left;
 margin: 0;
 width: 310px;
}
ul h3
{
 float: left;
 font-size: 14px;
 font-weight: bold;
 margin: 5px 0 0 0;
 width: 200px;
 margin-left:20px;
}
ul li
{
 border-bottom: 1px solid #DFDFDF;
 padding: 15px 0;
 width:600px;
 overflow:hidden;
}
ul input[type="text"],ul input[type="password"]
{
 width:300px;
 padding:5px;
 position:relative;
 border:solid 1px #666;
 -moz-border-radius:5px;
 -webkit-border-radius:5px;
}
ul input.required 
{
 border: solid 1px #f00;
}
</style>
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
 $("#signup").click(function() {
 resetFields();
 var emptyfields = $("input[value=]");
 if (emptyfields.size() > 0) {
  emptyfields.each(function() {
  $(this).stop()
   .animate({ left: "-10px" },100).animate({ left: "10px" },100)
   .animate({ left: "-10px" },100)
   .animate({ left: "0px" },100)
   .addClass("required");
  });
 }
 });
});
function resetFields() {
 $("input[type=text],input[type=password]").removeClass("required");
}
</script>
</head>
<body>
 <ul>
 <lihttps://www.jb51.cc/tag/irs/" target="_blank">irst">
  <h3>您的名字:</h3>
  <p><input type="text" value="First and Last name" id="name" name="name" /></p>
 </li>
 <li>
  <h3>Email地址:</h3>
  <p><input type="text" value="my@email.com" name="email" /></p>
 </li>
 <li>
  <h3>密码:</h3>
  <p><input type="password" name="passwd" /></p>
 </li>
 <li>
  <h3>密码确认:</h3>
  <p><input type="password" name="passwd_conf" /></p>
 </li>
 <li>
  <h3>用户名:</h3>
  <p><input type="text" value="MyUserName" id="userName" name="user_name" /></p>
 </li>
 <li>
  <a id="signup" href="#"><img src="images/buttonsubmit.png"/></a><img src="images/clickhere.png"/>
 </li>
 </ul>
</body>
</html>

希望本文所述对大家的jquery程序设计有所帮助。

jquery实现的回旋滚动效果完整实例【附demo源码下载】

jquery实现的回旋滚动效果完整实例【附demo源码下载】

本文实例讲述了jquery实现的回旋滚动效果。分享给大家供大家参考,具体如下:

这里分享一款回旋滚动效果,先上效果图:

具体代码如下:

rush:js;"> <Meta charset="UTF-8"> jquery-roundabout

今天关于js实现的简单图片浮动效果完整实例js实现图片滑动的介绍到此结束,谢谢您的阅读,有关C#实现3D效果完整实例、HTML+JS实现的简单图片轮播、jQuery实现动态表单验证时文本框抖动效果完整实例、jquery实现的回旋滚动效果完整实例【附demo源码下载】等更多相关知识的信息可以在本站进行查询。

本文标签:

上一篇全国省市二级联动下拉菜单 js版(js实现省市二级联动菜单)

下一篇使用CSS+JavaScript或纯js实现半透明遮罩效果的实例分享(css半透明遮罩层)