javascript 不移动元素
我正在尝试制作一个可点击的框来禁用转换 CSS。我正在尝试用 javascript 覆盖 CSS,但它似乎不起作用。我希望他们在单击 后简单地向左和向下移动一点,如果他们只关注
,他们就会在哪里。
.bigbox {
border: 2px solid black;
border-radius: 20px;
background-color: blue;
color: white;
padding-left: 15px;
}
#closebigbox {
padding: 10px;
border: 2px solid black;
border-radius: 20px;
background-color: blue;
color: white;
font-size: 8px;
width: 25px;
text-align: left;
background-color: silver;
}
.bigbox_submit{
padding: 3px;
border: 2px solid black;
border-radius: 20px;
background-color: blue;
color: white;
font-size: 12px;
width: 25px;
text-align: left;
background-color: silver;
}
.bigbox{
-moz-transition: all 0.5s ease-in-out;
}
.bigbox:focus {
background-color: #fc3;
-moz-transform: translate(125px,25px) scale(2);
}
<a href="javascript: document.getElementsByClassName('bigbox').style.position = 'relative'; document.getElementsByClassName('bigbox').style.left = '125px'; document.getElementsByClassName('bigbox').style.top = '25px';" id="closebigbox" >Clear</a>
<form>
<input type="text" class="bigbox" /><br/>
<input type="text" class="bigbox" /><br/>
<input type="text" class="bigbox" /><br/>
<a href="javascript:" class="bigbox_submit" >Submit</a>
</form>`
I'm trying make a click-able box to disable the transform CSS. I'm trying to overwrite the CSS with javascript but it dosn't seem to be working. I would like them to simply move to left and down a bit after clicking on the <a>
, where they would be if they just focused on the <input>
.
.bigbox {
border: 2px solid black;
border-radius: 20px;
background-color: blue;
color: white;
padding-left: 15px;
}
#closebigbox {
padding: 10px;
border: 2px solid black;
border-radius: 20px;
background-color: blue;
color: white;
font-size: 8px;
width: 25px;
text-align: left;
background-color: silver;
}
.bigbox_submit{
padding: 3px;
border: 2px solid black;
border-radius: 20px;
background-color: blue;
color: white;
font-size: 12px;
width: 25px;
text-align: left;
background-color: silver;
}
.bigbox{
-moz-transition: all 0.5s ease-in-out;
}
.bigbox:focus {
background-color: #fc3;
-moz-transform: translate(125px,25px) scale(2);
}
<a href="javascript: document.getElementsByClassName('bigbox').style.position = 'relative'; document.getElementsByClassName('bigbox').style.left = '125px'; document.getElementsByClassName('bigbox').style.top = '25px';" id="closebigbox" >Clear</a>
<form>
<input type="text" class="bigbox" /><br/>
<input type="text" class="bigbox" /><br/>
<input type="text" class="bigbox" /><br/>
<a href="javascript:" class="bigbox_submit" >Submit</a>
</form>`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
getElementsByClassName
返回一个数组,因此您需要循环遍历所有元素,然后应用样式:getElementsByClassName
returns an Array so you'll need to loop through all of the elements and then apply the style:尝试做这样的事情
Try doing something like this