基本上我试图将两个垂直按钮对齐我的网站的右侧。当我点击时,它会显示另一个帮助我jQuery动画的div。这里是我的html代码:垂直对齐按钮
<div id="rightBar">
<input type='button' id='hideshow' value='Show/Hide' />
<input type='button' id='hideshowBookmark' value='Bookmark' />
<div id='rightContent'>
<table style="width:100%; text-align: center;padding: 2px;">
<th colspan="2"><b>Get Directions</b></th>
<tr><td> </td></tr>
<tr>
<td width="120px"><label class="title">Get Location: </label></td>
<td><input id="txtFrom" type="text" class="textInput" placeholder="Outram" /> <img id="AutoFrom" src="img/map.jpg" class="button_search" onclick="GetDataFrom();"/> <label class="title">To</label> <input id="txtTo" type="text" class="textInput" placeholder="Hougang mall" /> <img id="AutoTo" src="img/map.jpg" class="button_search" onclick="GetDataTo();" /></td>
</tr>
</table>
<div id="divDirectionResults" style="display: none; border:1px solid black; opacity: 0.8; filter: progid:DXImageTransform.Microsoft.Alpha(opacity=80); background:#000000; width:auto; height:190px;"></div>
<table style="width:100%; text-align: center;padding: 2px;">
<tr>
<td colspan="2" style="padding-left:45px;"><input id="CbAvoid" type="checkbox" checked="checked" /> Avoid ERP</td>
</tr>
<tr><td> </td></tr>
<tr>
<td style="width: 35%;"> </td>
<td><input value="Get Routing" type="button" onClick="getDirections();" style="width: 109px; height: 23px;font-size:7pt;font-weight:bold;"/><input type="button" onclick="resetSearchField();" style="width: 58px; height: 23px;font-size: 7pt;font-weight:bold;" value="Reset"/></td>
</tr>
</table>
<div id="divComputedDirection">
</div>
</div>
</div>
而且我的JavaScript:
$(document).ready(function() {
$('#hideshow').click(function() {
$('#rightContent').animate({
width: 'toggle'
}, 1000
);
});
$('#hideshow').val('H\ni\nd\ne\n/\nS\nh\no\nw');
$('#hideshowBookmark').val('B\no\no\no\nk\nm\na\nr\nk');
});
而CSS:
#rightBar
{
float: right;
}
#hideshow
{
float: right;
padding: 10px;
background: linear-gradient(#81BEF7,#2E9AFE);
border-radius: 3px;
font-weight: bold;
border: 0;
}
#hideshow:active
{
outline:none;
}
#hideshowBookmark
{
float: right;
padding: 10px;
background: linear-gradient(#81BEF7,#2E9AFE);
border-radius: 3px;
font-weight: bold;
border: 0;
margin-top: 170px;
}
#hideshowBookmark:active
{
outline:none;
}
#rightContent
{
width: 320px;
height: 440px;
background-color: white;
display: none;
margin-right: 40px;
border-radius: 5px;
border: 1px solid grey;
}
不知何故,DIV中的元素向下移动,当我点击第一个按钮。而我的第二个按钮没有对齐到右侧。
这里是我的小提琴:Fiddle Link
我不知道为什么会这样呢?是因为我的CSS还是我放置html组件的方式?
在此先感谢。
它的工作原理!谢谢您的帮助! –
只是想知道为什么当我滑出div时,所有组件都在移动?你知道如何让自己的位置留下吗? –
这不完全是幻灯片。你正在使用'width'切换,所以里面的内容适应div扩展时的当前宽度。在StackOverflow中搜索解决方案,如果你没有找到它,你应该打开一个新的问题。 – Cthulhu