我正在處理的網站的標題包含公司徽標和搜索欄。我希望徽標顯示在右側,搜索欄位於左側,填充剩餘的可用空間。下面是它目前的樣子,你可以看到搜索欄已經下降到下一行:如何將我的元素全部顯示在同一行上?
而這裏的代碼:
HTML:
<p class="body-one">
<div id="navbar">
<div id="navbar-content">
<img src="http://i.imgur.com/SsSkZjU.png">
<script id="search-function">
(function() {
var cx = '008943255139580210842:rssvb04mkxs';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
</div>
<ul>
<li><b><a href="http://www.chaotixstudios.x10.mx/home.html">Chaotix Studios, LLC. - Since 2012</b></li>
<li><a href="http://www.chaotixstudios.x10.mx"><u>Home</u></a></li>
<li><a href="http://www.chaotixstudios.x10.mx/games.html"><u>Games & Gaming</u></a></li>
<li><a href="http://www.chaotixstudios.x10.mx/social.html">Social Media</a></li>
<li><a href="http://www.chaotixstudios.x10.mx/contact.html">Contact Us</a></li>
<li><a href="http://www.chaotixstudios.x10.mx/products.html">Products</a></li>
<div id="search">
</div>
</ul>
</div>
CSS:
<div id="whole">
<head>
<style type="text/css">
<!--
#navbar ul
{
margin: 7px;
padding: 5px;
list-style-type: none;
text-align: left;
background-color: #000;
font-family:Tahoma;
}
#navbar ul li {
display: inline;
}
#navbar ul li a {
text-decoration: none;
padding: .2em 1em;
color: #666666;
background-color: #000;
}
#navbar ul li a:hover
{
color: #000;
background-color: #949494;
}
#navbar b
{
color:#666666;
}
p.footer-one
{
text-align:Center;
font-family:Tahoma;
font-size:14px;
}
p.body-two
{
font-family:Tahoma;
}
p.footer-two
{
font-family:Tahoma;
font-size:10px;
color:#B8B8B8;
text-align:center;
}
#search-function
{
float:center;
}
-->
</style>
</head>
這是想什麼我它看起來像一個篡改圖像:
,我想你可以在導航欄的'display'設置爲'直列block',浮動的權利,並確保寬度是不是太大 – cubrr
@cimmanon是的,第二個圖像的徽標旁邊有搜索欄。 – yozo67
將來,如果將示例代碼剝離到重現問題所需的最小數量,那將非常有用。 – cimmanon