1. html圖片切換點作用
html圖片切換點作用:var name = //[0-9]+.png/.exec($(this).attr('src'));var num = /[0-9]/.exec(name);$(this).attr('src', 'images/' + num + '.' + num + '.png');})。
就將src="http://image2.sina.com.cn/bj/zonghe/pixviewer.swf" 替換為你本地路徑的src="pixviewer.swf",PS:你也可以直接用它的FLASH。
也就是說這個地方可以不用改,然後你將flashvars="pics="後面所有帶有.jpg擴展名的,都改為你本地的圖片路徑就可以了,但最好圖片為width="700" height="527" 大小,否則圖片會失幀。
編輯:
基本文本、文檔編輯軟體,使用微軟自帶的記事本或寫字板都可以編寫,當然,如果你用WPS或Word來編寫也可以,不過保存時請使用.htm或.html作為擴展名,這樣就方便瀏覽器認出直接解釋執行了。
所見即所得軟體,使用最廣泛的編輯器,完全可以一點不懂HTML的知識就可以做出網頁,如:AMAYA(出品單位:萬維網聯盟);FRONTPAGE(出品單位:微軟);Dreamweaver(出品單位Adobe)。
2. html中如何設置圖片切換
html是無法設置圖片切換的,需要結合js或jquery等相關技術實現。
你可以網路下:js或jquery實現圖片切換效果,範例代碼超級多,根據他們的修改即可。
3. html怎麼實現當滑鼠經過一個圖片時顯示另一張圖片
1、准備切換圖片素材,一般是兩張,如圖,放入img文件夾,跟HTML同級。
4. 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、實現效果
5. 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>
6. 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>
7. 在HTML中用css如何實現圖片切換!!!
該圖片切換特效實現很簡單,而且兼容性很好。
html頁面如下
<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>
<li><a href="http://www.lanrentuku.com/" target="_blank"><img src="img/02.jpg" alt="QQ商城焦點圖效果教程" /></a></li>
<li><a href="http://www.lanrentuku.com/" target="_blank"><img src="img/03.jpg" alt="jquery商城焦點圖效果" /></a></li>
<li><a href="http://www.lanrentuku.com/" target="_blank"><img src="img/04.jpg" alt="jquery商城焦點圖代碼" /></a></li>
<li><a href="http://www.lanrentuku.com/" target="_blank"><img src="img/05.jpg" alt="jquery商城焦點圖源碼" /></a></li>
</ul>
</div>
</div><!-- wrapper end -->
</body>
css樣式
<style type="text/css">
* {margin:0; padding:0;}
body {font-size:12px; color:#222; font-family:Verdana,Arial,Helvetica,sans-serif; background:#f0f0f0;}
.clearfix:after {content: "."; display: block; height: 0; clear: both; visibility: hidden;}
.clearfix {zoom:1;}
ul,li {list-style:none;}
img {border:0;}
.wrapper {width:800px; margin:0 auto; padding-bottom:50px;}
/* qqshop focus */
#focus {width:800px; height:280px; overflow:hidden; position:relative;}
#focus ul {height:380px; position:absolute;}
#focus ul li {float:left; width:800px; height:280px; overflow:hidden; position:relative; background:#000;}
#focus ul li div {position:absolute; overflow:hidden;}
#focus .btnBg {position:absolute; width:800px; height:20px; left:0; bottom:0; background:#000;}
#focus .btn {position:absolute; width:780px; height:10px; padding:5px 10px; right:0; bottom:0; text-align:right;}
#focus .btn span {display:inline-block; _display:inline; _zoom:1; width:25px; height:10px; _font-size:0; margin-left:5px; cursor:pointer; background:#fff;}
#focus .btn span.on {background:#fff;}
#focus .preNext {width:45px; height:100px; position:absolute; top:90px; background:url(img/sprite.png) no-repeat 0 0; cursor:pointer;}
#focus .pre {left:0;}
#focus .next {right:0; background-position:right top;}
</style>
js腳本
$(function() {
var sWidth = $("#focus").width(); //獲取焦點圖的寬度(顯示面積)
var len = $("#focus ul li").length; //獲取焦點圖個數
var index = 0;
var picTimer;
//以下代碼添加數字按鈕和按鈕後的半透明條,還有上一頁、下一頁兩個按鈕
var btn = "<div class='btnBg'></div><div class='btn'>";
for(var i=0; i < len; i++) {
btn += "<span></span>";
}
btn += "</div><div class='preNext pre'></div><div class='preNext next'></div>";
$("#focus").append(btn);
$("#focus .btnBg").css("opacity",0.5);
//為小按鈕添加滑鼠滑入事件,以顯示相應的內容
$("#focus .btn span").css("opacity",0.4).mouseenter(function() {
index = $("#focus .btn span").index(this);
showPics(index);
}).eq(0).trigger("mouseenter");
//上一頁、下一頁按鈕透明度處理
$("#focus .preNext").css("opacity",0.2).hover(function() {
$(this).stop(true,false).animate({"opacity":"0.5"},300);
},function() {
$(this).stop(true,false).animate({"opacity":"0.2"},300);
});
//上一頁按鈕
$("#focus .pre").click(function() {
index -= 1;
if(index == -1) {index = len - 1;}
showPics(index);
});
//下一頁按鈕
$("#focus .next").click(function() {
index += 1;
if(index == len) {index = 0;}
showPics(index);
});
//本例為左右滾動,即所有li元素都是在同一排向左浮動,所以這里需要計算出外圍ul元素的寬度
$("#focus ul").css("width",sWidth * (len));
//滑鼠滑上焦點圖時停止自動播放,滑出時開始自動播放
$("#focus").hover(function() {
clearInterval(picTimer);
},function() {
picTimer = setInterval(function() {
showPics(index);
index++;
if(index == len) {index = 0;}
},4000); //此4000代表自動播放的間隔,單位:毫秒
}).trigger("mouseleave");
//顯示圖片函數,根據接收的index值顯示相應的內容
function showPics(index) { //普通切換
var nowLeft = -index*sWidth; //根據index值計算ul元素的left值
$("#focus ul").stop(true,false).animate({"left":nowLeft},300); //通過animate()調整ul元素滾動到計算出的position
//$("#focus .btn span").removeClass("on").eq(index).addClass("on"); //為當前的按鈕切換到選中的效果
$("#focus .btn span").stop(true,false).animate({"opacity":"0.4"},300).eq(index).stop(true,false).animate({"opacity":"1"},300); //為當前的按鈕切換到選中的效果
}
});
用到的左右切換圖片
8. HTML怎麼設置點擊一張圖片換一張圖片
需要准備的材料分別有:電腦、瀏覽器、html編輯器。
1、首先,打開html編輯器,新建html文件,例如:index.html,編寫問題基礎代碼。
9. html怎樣實現圖片自動切換
1、首先,打開html編輯器,新建html文件,例如:index.html。