當前位置:首頁 » 背景圖片 » 切換背景圖片
擴展閱讀
漫畫頭像高清手繪圖片 2024-10-05 11:09:44
兒童手工裙子圖片大全 2024-10-05 11:04:59
做紅包圖片軟體有哪些 2024-10-05 10:54:07

切換背景圖片

發布時間: 2022-01-07 05:43:51

Ⅰ jquery點擊來回切換背景圖片的background-position

<span class="w-open" onclick="switch_pic(this);"></span>

你應該還有一個class="w-close"吧?表示上門取車的背景圖樣式。

functionswitch_pic(this){
if($(this).attr('class')=='w-open'){
$(this).attr('class','w-close');
}else{
$(this).attr('class','w-open');
}
}

Ⅱ js點擊切換背景圖片

style.backgroundImage = ='url("??????")'
判斷換成這個
style.backgroundImage ='url("??????")'
賦值換這個
因為你加的url裡面的 不是string 不合法,js自動給你加上了「」

Ⅲ html 製作一個導航,點擊後切換背景圖片.

<style>
.a1{
background-color:#006666;
color:#FFFFFF;}

.a2{
background-color:#6600CC;
color:#FFFFFF}
</style>
<script>
function change(x)
{
for(h=0;h<2;h++){
document.getElementById("cia"+h).className='a1'
document.getElementById("cia"+x).className='a2'
}
}
</script>
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" class="a1" onMouseOver="change(0)" id="cia0">欄目1</td>
<td align="center" class="a1" onMouseOver="change(1)" id="cia1">欄目2</td>
</tr>
</table>

Ⅳ html中,點擊div,使其更換背景圖片,兩張圖片來回切換

<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8">
<title>無標題文檔</title>
</head>

<body>
<scriptsrc="模板/js/jquery-1.8.0.js"></script>
<script>
$(function(){
$('#div1').toggle(
function(){
$(this).css('background','blue')
},
function(){

$(this).css('background','red')
}
)
})
</script>


<divstyle="background:red;width:50px;height:50px"id='div1'></div>
</body>
</html>


Ⅳ jquery怎麼實現點擊一個元素更換背景圖片,連續點擊永遠在2張圖片之間更換

實現的方法和操作步驟如下:

1、首先,打開html編輯器,創建一個新的html文件,例如index.html,然後引入jquery,如下圖所示。

Ⅵ 怎麼把圖片切換背景

你說的是不是人物的背景怎麼換成這樣的吧,當然,你要是需要的話我會把你的照片換成任何背景,比如什麼鳥巢啊,世博會啊等等。
從技術上是用圖片處理工具合成的,一般可以用photoshop,你需要的話,我幫你,當然要加分。嗨我!

Ⅶ Html按鈕點擊後會變換背景圖片

這種更換背景的問題 一般來說 是由於 後台伺服器的響應 和你前端之間的不是實時傳送有一定關系 所以 這個不是大問題

Ⅷ 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中背景圖片,滑鼠移動上去之後切換為另一個圖片

a:hover{
background-img:url(a.jpg);
}