导航:首页 > 动漫图片 > html怎么换图片

html怎么换图片

发布时间:2023-10-14 02:08:50

‘壹’ HTML 里面的图片怎么移动位置

需要准备的材料分别有:电脑、chrome浏览器、html编辑器。

1、首先,打开html编辑器,新建一个html文件,例如:index.html,填充问题基础代码。

‘贰’ HTML怎么设置切换图片

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>H5course</title>
<link rel="stylesheet" href="css/reset.css">
<style>
.imgview {
width: 255px;
height: 402px;
margin: 50px auto;
border: 10px solid red;
overflow: hidden;
}
.imgview img {
width: 255px;
height: 402px;
}
.imgview-nav {
width: 255px;
margin: 10px auto;
border: 1px solid red;
list-style-type: none;
}
.imgview-nav li {
float: left;
width: 15px;
height: 15px;
border: 1px solid blue;
margin: 10px;
}
span {
display: inline-block;
width: 50px;
height: 50px;
background: #CFC;
border-radius: 50%;
}
</style>
</head>
<body>
<div class="wrap">
<div class="imgview" id="imgView">
<table cellspacing="0" cellpadding="0">
<tr>
<td><img src="img/1.jpg" alt=""></td>
<td><img src="img/2.jpg" alt=""></td>
<td><img src="img/3.jpg" alt=""></td>
<td><img src="img/4.jpg" alt=""></td>
<td><img src="img/5.jpg" alt=""></td>
<td><img src="img/6.jpg" alt=""></td>

</tr>
</table>
</div>
<ul class="imgview-nav" id="imgviewNav">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
<span>左边</span>
<span>右边</span>
</div>
<script>
var imgView = document.getElementById('imgView'),
imgWidth = imgView.getElementsByTagName('img'),
btn = document.getElementsByTagName('li'),
len = btn.length,
imgNum = 0,
endPos = 0,
timer = null,
timer2 = null,
conSpan = document.getElementsByTagName('span');

conSpan[0].onclick = function (){
if (timer) {
clearInterval(timer);
};
if (timer2) {
clearInterval(timer2);
};
imgNum--;
if (imgNum < 0 ) {
imgNum = len;
};
timer = setInterval(move, 16);
timer2 = setInterval(autoMove, 3000);
}
conSpan[1].onclick = function (){
if (timer) {
clearInterval(timer);
};
if (timer2) {
clearInterval(timer2);
};
imgNum++;
if (imgNum == len ) {
imgNum = 0;
};
timer = setInterval(move, 16);
timer2 = setInterval(autoMove, 3000);
}
//绑定事件。添加移动效果
for (var i = 0; i < len; i++) {
btn[i].index = i;
btn[i].onmouseover = function(){
clearInterval(timer2);
imgNum = this.index;
if (timer) {
clearInterval(timer);
};
timer = setInterval(move, 16);
}
btn[i].onmouseout = function(){
timer2 = setInterval(autoMove, 2000);
}
};
//图片缓动效果,原理是保持步数不变,改变距离的同时改变速度
function move(){
var starPos = imgView.scrollLeft,
speed;
endPos = imgNum * imgWidth[0].offsetWidth;
speed = (endPos - starPos) / 20;
if (speed == 0) {
clearInterval(timer);
} else if(speed > 0){
speed = Math.ceil(speed);
} else {
speed = Math.floor(speed);
}
imgView.scrollLeft = starPos + speed;

}
//控制图片的自动滚动,通过控制索引值来控制图片的自动滚动
function autoMove(){
imgNum++;
if(imgNum == len) {
imgNum = 0;
};
timer = setInterval(move, 20);
}timer2 = setInterval(autoMove, 2000);
</script>
</body>
</html>

‘叁’ html怎么实现当鼠标经过一个图片时显示另一张图片

1、准备切换图片素材,一般是两张,如图,放入img文件夹,跟HTML同级。

‘肆’ html如何调整图片位置

1、可以使用background-position属性设置脊悔高图片位置前渗,具体的方法是,首先用hbuilder软件新建一个html文件,文件的head标签中设置输入style标签:

‘伍’ html中如何鼠标点击更换背景图片

html中鼠标点击更换背景图片的方法:

1、html代码:

<div id="menuWrapper" class="menuWrapper bg1">

<ul class="menu" id="menu">

<li class="bg1" style="background-position:0 0;">

<a id="bg1" href="#">迈瑞宝</a>

<ul class="sub1" style="background-position:0 0;">

<li><a href="#">报价:11.99-23.69万</a></li>

<li><a href="#">车身结构:三箱</a></li>

<li><a href="#">油耗:8.3-12.0L</a></li>

</ul>

</li>

<li class="bg1" style="background-position:-266px 0px;">

<a id="bg2" href="#">索纳塔8</a>

<ul class="sub2" style="background-position:-266px 0;">

<li><a href="#">报价:13.39-22.59万</a></li>

<li><a href="#">车身结构:三箱</a></li>

<li><a href="#">油耗:9.0-12.0L</a></li>

</ul>

</li>

<li class="last bg1" style="background-position:-532px 0px;">

<a id="bg3" href="#">K5</a>

<ul class="sub3" style="background-position:-266px 0;">

<li><a href="#">报价:10.88-25.58万</a></li>

<li><a href="#">车身结构:三箱</a></li>

<li><a href="#">油耗:8.4-13.0L</a></li>

</ul>

</li>

</ul>

</div>

2、css代码:

ul.menu > li > a{

float:left;

width:265px;

height:50px;

margin-top:450px;

text-align:center;

line-height:50px;

color:#ddd;

background-color:#333;

letter-spacing:1px;

cursor:pointer;

text-decoration:none;

text-shadow:0px 0px 1px #fff;

}

ul.menu > li ul{

list-style:none;

float:left;

margin-top:-180px;

width:100%;

height:110px;

padding-top:20px;

background-repeat:no-repeat;

background-color:transparent;

}

ul.menu > li ul li{

display:none;

}

ul.menu > li ul.sub1 {

background-image: url('../img/bg1sub.png');

}

ul.menu > li ul.sub2 {

background-image: url('../img/bg2sub.png');

}

ul.menu > li ul.sub3{

background-image:url(../img/bg3sub.png);

}

ul.menu > li ul li a{

color:#fff;

text-decoration:none;

line-height:30px;

margin-left:20px;

text-shadow:1px 1px 1px #444;

font-size:11px;

}

ul.menu > li ul li a:hover{

border-bottom:1px dotted #fff;

}

ul.menu > li ul.sub1 li{

display:block;

}

3、js代码:

if (!document.defaultView || !document.defaultView.getComputedStyle) { // IE6-IE8

var oldCurCSS = jQuery.curCSS;

jQuery.curCSS = function (elem, name, force) {

if (name === 'background-position') {

name = 'backgroundPosition';

}

if (name !== 'backgroundPosition' || !elem.currentStyle || elem.currentStyle[name]) {

return oldCurCSS.apply(this, arguments);

}

var style = elem.style;

if (!force && style && style[name]) {

return style[name];

}

return oldCurCSS(elem, 'backgroundPositionX', force) + ' ' + oldCurCSS(elem, 'backgroundPositionY', force);

};

}

var oldAnim = $.fn.animate;

$.fn.animate = function (prop) {

if ('background-position' in prop) {

prop.backgroundPosition = prop['background-position'];

delete prop['background-position'];

}

if ('backgroundPosition' in prop) {

prop.backgroundPosition = '(' + prop.backgroundPosition;

}

return oldAnim.apply(this, arguments);

};

function toArray(strg) {

strg = strg.replace(/left|top/g, '0px');

strg = strg.replace(/right|bottom/g, '100%');

strg = strg.replace(/([0-9.]+)(s|)|$)/g, "$1px$2");

var res = strg.match(/(-?[0-9.]+)(px|\%|em|pt)s(-?[0-9.]+)(px|\%|em|pt)/);

return [parseFloat(res[1], 10), res[2], parseFloat(res[3], 10), res[4]];

}

4、实现效果

‘陆’ html怎样实现图片自动切换

1、首先,打开html编辑器,新建html文件,例如:index.html。

‘柒’ html5点击链接在框架内更换图片

你好 这种效果很简单的 采用jquery 然后 假设 另一张图片名叫 a.gif 并且和 depart_info_close.gif存放在同一个文件夹下 给a标签新加一个属性 id="a" 然后按照你提供的高袭 html结构 代码如戚谨兄下
$(function(){
$("#a").click(function(){
$(this).prev().attr({"src":"a.gif"});
});
})
这样子就好了
代码的晌拆意思是 当点击a标签时 寻找与他同级的 并且在他之前的那一个元素 也就是img标签
并且改变 img标签中的 src属性 为 a.gif
希望能帮到你 谢谢

‘捌’ html中的如何图片切换 如图

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "团迹http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">帆胡
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN" xml:lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style>
p,ul,li {
margin: 0;
padding: 0;
}

body,input {
font: 12px/ 1.5 Helvetica, Tahoma, Arial, \5b8b\4f53, sans-serif;
}

a {
text-decoration: none;
color: #000;
}

a:hover {
text-decoration: underline;
color: #000;
}

a img {
vertical-align: text-bottom;
}

.pic-news {
width: 295px;
}

.news-slider {
position: relative;
z-index: 88;
height: 200px;
padding: 3px 0 0 5px;
margin-bottom: 10px;
}

.news-slider .slides_container {
display: none;
position: relative;
width: 284px;
overflow: hidden;
}

.news-slider .slides_container div.slide {
display: block;
width: 284px;
height: 200px;
}

.news-slider .caption {
position: absolute;
bottom: -35px;
left: 0;
z-index: 500;
width: 204px;
height: 24px;
line-height: 24px;
_height: 30px;
overflow: hidden;
padding: 0 70px 0 10px;
border-top: 1px solid #000;
background: #000;
opacity: 0.8;
filter: alpha(opacity = 80);
color: #fff;
text-shadow: none;
}

.news-slider .pagination {
position: absolute;
bottom: 0;
right: 0;
z-index: 99;
height: 16px;
width: 70px;
}

.news-slider .pagination li {
float: left;
margin: 0 2px;
list-style: none;
}

.news-slider .pagination li a {
float: left;
display: block;
width: 8px;
height: 8px;
overflow: hidden;
background: url(../images/pagination.png);
_background: url(../images/pagination.gif);
font-size: 0;
}

.news-slider .pagination li.current a {
background-position: 0 -12px;
}
</style>
</head>
<body>
<div class="fl pic-news">
<div id="J_news_slider" class="news-slider">
<div class="slides_container">
<div class="slide">
<img src="images/slider/s1.jpg" width="态或拦300" height="206" alt="" />
<div class="caption" style="bottom: 0">
<p>
图1
</p>
</div>
</div>
<div class="slide">
<img src="images/slider/s2.jpg" width="300" height="206" alt="" />
<div class="caption">
<p>
图2
</p>
</div>
</div>
<div class="slide">
<img src="images/slider/s3.jpg" width="300" height="206" alt="" />
<div class="caption">
<p>
图3
</p>
</div>
</div>
<div class="slide">
<img src="images/slider/s4.jpg" width="300" height="206" alt="" />
<div class="caption">
<p>
图4
</p>
</div>
</div>
<div class="slide">
<img src="images/slider/s5.jpg" width="300" height="206" alt="" />
<div class="caption">
<p>
图5
</p>
</div>
</div>
</div>
<ul class="pagination">
<li>
<a href="#">1</a>
</li>
<li>
<a href="#">2</a>
</li>
<li>
<a href="#">3</a>
</li>
<li>
<a href="#">4</a>
</li>
<li>
<a href="#">5</a>
</li>
</ul>
</div>
</div>

<script type="text/javascript" src="js/libs/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/libs/slides.min.jquery.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
if($('#J_news_slider').length>0){
/*slides*/
$('#J_news_slider').slides({
preload: true,
preloadImage: 'images/loading.gif',
play: 5000,
pause: 2500,
hoverPause: true,
generateNextPrev: false,
generatePagination: false,
animationStart: function(current){
$('.caption').animate({
bottom:-35
},100);
if (window.console && console.log) {
// example return of current slide number
console.log('animationStart on slide: ', current);
};
},
animationComplete: function(current){
$('.caption').animate({
bottom:0
},200);
if (window.console && console.log) {
// example return of current slide number
console.log('animationComplete on slide: ', current);
};
},
slidesLoaded: function() {
$('.caption').animate({
bottom:0
},200);
}
});
}
});
</script>
</body>
</html>
图片放/image/slider/目录下,最后,jquery-1.6.2.min.js与slides.min.jquery.js可在网上下载,放在/js/libs/目录下

‘玖’ HTML中如何做图片切换效果,跪求代码

1、首先输入代码:

<div class="wrapper">

<div id="focus">

<ul>

<li><a href="http://www.lanrentuku.com/" target="_blank"><img src="img/01.jpg" alt="QQ商城焦点图效果下载" /></a></li>

阅读全文

与html怎么换图片相关的资料

热点内容
老鼠图案简单漂亮图片 浏览:56
如何右键保存网页图片 浏览:214
奇迹暖暖人物图片女生可爱 浏览:847
如何用ps把圆形图片变成方的 浏览:890
word图片两张排一页 浏览:232
露肩膀图片美女背面 浏览:270
电脑画图如何截图半圆形图片 浏览:794
小清新图片卡通头像女生头像 浏览:178
如何用扫描全能王把图片处理小 浏览:441
怎么画鱼的图片 浏览:477
男老年人衣服穿搭图片 浏览:797
卡通男生的图片可爱 浏览:219
衣服破烂的卡通女孩图片 浏览:544
插入文字图片如何去掉背景颜色 浏览:918
三星分屏如何拖拽图片 浏览:230
图片如何免费去掉水印 浏览:242
穿着可爱的权子图片 浏览:738
漫画女生哭泣图片唯美 浏览:862
西装成年男生图片 浏览:821
斜背发型图片男 浏览:624