我在页面底部添加了固定条,首先我有100%宽度的固定容器,其中包含2个元素。第一个是内容,第二个关闭吧。当第二个浮动右边时,浮动中心的右边元素
欲第一元件,即,“mixtext”在酒吧中居中,和第二元件,关闭按钮为始终在正确的,我想他们是在同一行上。你能建议我该怎么做?
下面是HTML代码:
<div id="mixwrap">
<span id="mixtext">
[Text that needs to be centered within the space from left to the next element]
</span>
<span id="mixclose">
<input type="button" id="mixclosebut" onclick="document.getElementById('mixwrap').style.display = 'none';">
</span>
</div>
和CSS:
#mixwrap {
left: 0;
bottom: 0;
position: fixed;
width: 100%;
background: #555;
color: white;
}
#mixtext {
text-align: center;
padding: 8px;
font-family: MetaBold, "Trebuchet MS", sans-serif;
float: left;
}
#mixclose {
cursor: pointer;
float: right;
}
另外,我要记住用户的选择,当有人点击关闭按钮,JS只是设置显示:没有了元素,但是当用户导航到其他页面时,div会再次显示。如何隐藏它以便用户在导航到其他页面后不会看到它?
在此先感谢。从#mixtext
CSS
<div id="mixwrap">
<div id="mixclose"><input type="button" id="mixclosebut"
value="Test" onclick="document.getElementById('mixwrap').style.display = 'none';">
</div>
<div id="mixtext">
[Text that needs to be centered within the space from left to the next element]
</div>
</div>
并删除float: left
: