当前位置:首页 » 背景图片 » 切换背景图片
扩展阅读
修改头像图片的软件 2024-10-05 13:18:35
ps怎么看图片的尺寸 2024-10-05 12:15:56
卡通中国人民解放军图片 2024-10-05 12:10:45

切换背景图片

发布时间: 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);
}