css - 在标题上定位搜索栏

标签 css

我在标题上有一个 Logo 和搜索栏。 Logo 位于左上角。我想要标题中心的搜索栏。我试过它的一半隐藏在导航菜单中。这是一个粗略的 jsfiddle

#header  {
    position:relative; 
    float:left; 
    clear:both; 
    width:100%; 
    height:110px; 
    background:url("resources/images/logo.jpg") repeat-y; 
    font-size:30px;
    background:#ccc;
    }

#header img {
    position:relative; 
    left:20px; 
    top:13px; 
    border:0;
}

#header-search {
    position:relative; 
    left:220px; 
} 

最佳答案

试试这个

#header img#header-search 使用float 和额外的margin 来自定义间距.

#header  {
    position:relative; 
    float:left; 
    clear:both; 
    width:100%; 
    height:110px; 
    background:url("resources/images/logo.jpg") repeat-y; 
    font-size:30px;
    background:#ccc;
    }

#header img {
    position:relative; 
    left:20px; 
    top:13px; 
    border:0;
    float: left;
}

#header-search {
    position:relative; 
    float: left;
    margin-left: 40px;
    margin-top: 30px; 
}

JSFiddle

关于css - 在标题上定位搜索栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26885998/

相关文章:

css - 我的专栏内容换行到一个新的专栏中间内容

javascript - 如何通过分区嵌套使字体变小?

javascript - 是否可以删除对整个 div 的特定区域的 css 模糊效果

javascript - 对齐 <div> 屏幕中心 - 最兼容的版本

html - 由于水平溢出, float 在调整大小时停止

css - 如何使用 Bootstrap 为不同的屏幕尺寸设置列类

html - Django 开发服务器不提供 bootstrap 3 glyphicons

javascript - CSS - 类添加/删除的过渡动画

html - CSS 背景渐变未按预期工作

html - 换行符(在代码中)导致 HTML 输出中不需要的边距