gpt4 book ai didi

javascript - firefox 不尊重 float 方向的 javascript 更改

转载 作者:行者123 更新时间:2023-12-01 23:19:12 25 4
gpt4 key购买 nike

此代码适用于除 firefox 之外的所有主要浏览器,firefox 说它已完成我的要求,但它没有。这让我疯狂。这是完整的 html、css 和 javascript:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html>
<head>
<style type=text/css>
.CastPic
{
position : relative;
top : +0px;
width : 250px;
height : 250px;
padding-top : 25px;
padding-left : 25px;
padding-right : 25px;
padding-bottom : 25px;
background-image : url('Cast photos/Fiona Colquhoun.jpg');
background-color : ivory;
background-repeat : no-repeat;
background-position : center;
cursor : pointer;
border-style : solid;
border-width : 12px;
border-color : green;
float : left;
}
</style>
<script language="JavaScript" type="text/JavaScript">
function toggle()
{
if (document.getElementById("CastPic").style.float =="right")
{
document.myForm.msg.value = "float is right"
document.getElementById("CastPic").style.float="left"
document.getElementById("CastPic").style.borderColor="red"
}
else
{
document.myForm.msg.value = "float is left"
document.getElementById("CastPic").style.float="right"
document.getElementById("CastPic").style.borderColor="blue"
}
document.myForm.msg.value = 'float is now ' + document.getElementById("CastPic").style.float
}
</script>
</head>
<body>
<div class="CastPic" id="CastPic"></div>
<form name="myForm" enctype="application/x-www-form-urlencoded">
<input type="text" name="msg" value="" size=65>
<input type="button" value="Switch" onClick="toggle()">
</form>
</body>
</html>

这当然只是一个测试脚本 - 我提取了这个位只是为了看看是否有其他影响它。我什么也看不见。

蒂亚阿德里安

最佳答案

http://www.iamseree.com/application-development/use-javascript-to-change-float-style

document.getElementById("CastPic").style.cssFloat="left" 

代码警告!!

关于javascript - firefox 不尊重 float 方向的 javascript 更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9290989/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com