【问题标题】:CSS search box how to keep it responsiveCSS搜索框如何保持响应
【发布时间】:2014-03-07 14:02:53
【问题描述】:

我需要一点帮助来让我的搜索框响应

HTML:

<div class="span12">
    <div id='search-box'>
        <form action='/search' id='search-form' method='get' target='_top'>
            <input class='search-text' name='q' placeholder='Search by name' type='text'/>
            <button id='search-button' type='submit'>src</button>
        </form>
    </div>
</div>

CSS:

#search-box {
    width:100%;
    height:44px;
    background:#ffd965;
    border-bottom:1px solid #fff;
    display:block;
}

#search-form {
    positoin:absolute;
    left:16px;
    right:16px;
    width:100%;
    height:30px;
    background-color:#fff;
    display:block;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
}

#search-text {
    width:100%;
    height:25px;
    background:  transparent;       
}

#search-box input[type="text"] {

}

#search-button {
    position: absolute;
    top: 0;
    left: 15px;
    height: 42px;
    width: 30px;
    text-align: center;
    border-width: 0;
    background-color: transparent ;
    background-image:url('../images/search.png');
    background-repeat:no-repeat;
}

我的代码是:JSFiddle

【问题讨论】:

  • 使用 MediaQueries。您是开发人员吗?设计师?
  • 您应该详细说明您正在寻找的行为。
  • 我尝试上传图片,但据说您至少需要 10 个赞才能上传图片。:@Shannon
  • 我也需要它,因为我们可以在移动设备中看到搜索框,是的,这将是移动应用程序的搜索框。 @香农
  • 但首先需要修复全宽:当我们将其设为 100% 时,它会脱离 div 格式。

标签: css html responsive-design fluid-layout


【解决方案1】:

试试这个

.search-text {
    width:50%;
}

看到这个

http://jsfiddle.net/La9r6/2/

【讨论】:

  • Jay,它将在响应后将搜索框显示为原来的一半。如果她使用已设置为 50% 的 class="span6"。但搜索框必须保持在 50% div 内 100%
  • 您现在可以将上述宽度修改为 100% 或您想要设置的任何尺寸。看到这个jsfiddle.net/La9r6/3
  • 但我 100% 需要它,就像手机中的搜索框一样。和两个尺寸(左右)的 10px 边距
  • 当我们 100% 完成时,它会从主包装盒中消失,看起来很丑:(@JayDeepNimavat,
  • @LOTUSMS 当我们 100% 完成时,它会从主包装盒中取出,看起来很丑:(
猜你喜欢
  • 2014-02-17
  • 2015-01-20
  • 1970-01-01
  • 2016-09-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多