我在頁面底部添加了固定條,首先我有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
: