【发布时间】:2014-02-13 21:48:39
【问题描述】:
我正在处理的网站的标题包含公司徽标和搜索栏。我希望徽标出现在右侧,搜索栏在左侧,填充剩余的可用空间。这是它目前的样子,你可以看到搜索栏已经下降到下一行:
这是代码:
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设置为inline-block,让它浮动并确保宽度不要太大 -
@cimmanon 是的,第二张图片的徽标旁边有搜索栏。
-
将来,如果您将示例代码精简到重现问题所需的最小量,这将非常有帮助。
标签: javascript html css header google-custom-search