gpt4 book ai didi

html - CSS3 搜索框响应,搜索按钮分解

转载 作者:行者123 更新时间:2023-11-28 06:35:13 25 4
gpt4 key购买 nike

我想为我的网站设计一个响应式搜索框,所以当我找到这个 codepen fiddle - http://codepen.io/nikhil/pen/GuAho ,我摆弄它并最终得到了这个版本 - http://codepen.io/anon/pen/Qygrpe

<!-- language: lang-css -->

/* CSS Search */

.cf:before, .cf:after{
content:"";
display:table;
}

.cf:after{
clear:both;
}

.cf{
zoom:1;
}

/*-------------------------------------*/

.content-wrapper {
width: 180px;
padding: 0px;
position:relative;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;

}

#search {
position:relative;
font-size:13px;font-family:"Dosis";
float:right;
margin-top:7px;
right:5px;
}
#search-form {
background-color:#314d5b;
height:32px;
line-height:32px;
border:0 none;
font-family:"Dosis";
font-size:13px;
font-weight:200;
color:#b5c5ca;
width:130px;
-moz-border-radius: 4px 0 0 4px;
-webkit-border-radius: 4px 0 0 4px;
border-radius: 4px 0 0 4px;
box-shadow:inset 0 0 1px 0 rgba(0,0,0,0.2);
padding:0 10px;
transition:all 0.5s ease 0s;
}
#search-form .search-button,#search-form .search-button:hover{
transition:all 0.5s ease 0s;
height:21px;
width:21px;
line-height:30px;
background-color:#ed0b77;
border:0 none;
float:right;
cursor:pointer;
outline:none;
}
#search-form:hover{
background-color:#f0f0f0;
}
#search-form:focus{
background-color:#eee;
text-shadow:none !important;
outline:none;
color:#459bb6;
}
#box {display:none}
.search-text {
font-size:13px;
font-family:"Dosis";
float:right;
cursor:pointer;
}
.search-text:hover {
color:#459bb6
}


.content-wrapper button {
overflow: visible;
position: relative;
float: right;
border: 0;
padding: 0;
cursor: pointer;
height: 32px;
width: 30px;
background: #416577;
-moz-border-radius: 0 3px 3px 0;
-webkit-border-radius: 0 3px 3px 0;
border-radius: 0 3px 3px 0;
text-shadow: 0 -1px 0 rgba(0, 0 ,0, .3);
}

.content-wrapper button:hover{
background: #e2614c;
}

.content-wrapper button:active,
.content-wrapper button:focus{
background: #c42f2f;
}

.content-wrapper button:before {
content: '';
position: absolute;
border-width: 8px 8px 8px 0;
border-style: solid solid solid none;
border-color: transparent #416577 transparent;
top: 8px;
left: -5px;
}

.content-wrapper button:hover:before{
border-right-color: #e2614c;
}

.content-wrapper button:focus:before{
border-right-color: #c42f2f;
}

.content-wrapper button::-moz-focus-inner {
border: 0;
padding: 0;
}


<!-- language: lang-html -->

<div id='search'>
<div class='content-wrapper cf'>
<form action='/search' id='searchform' method='get'>
<input id='search-form' name='q' onblur='if(this.value==&apos;&apos;)this.value=this.defaultValue;' onfocus='if(this.value==this.defaultValue)this.value=&apos;&apos;' type='text' value='Looking for something?'/>
<button class='search-button' title='Search' type='submit'><img alt='search button' src='http://4.bp.blogspot.com/-e8Tp2vSgy2c/VpS0vc8zi7I/AAAAAAAAAN0/6rDw0GIVaSg/s1600/mysearch2.png' title='Search'/>
</button>
</form>
</div>
</div>

我将搜索框的 HTML 代码及其 CSS 添加到我的博客模板中,在屏幕宽度超过 600 像素之前它都能很好地显示。看看

enter image description here

但是一旦宽度变为 600 像素或更小,我的搜索框就会分崩离析并且不会 float 在右侧,即使有足够的空间也是如此。我什至删除了菜单的几个部分,只留下“BLOGGER”和“MUSIC”,但搜索框仍然脱离了 div。

enter image description here

请指出我哪里出错了,我确定我在 CSS 的某个地方走错了方向。提前致谢。

最佳答案

尝试添加这个解决方案:

.content-wrapper {
width: auto;
}
#search {
position: absolute; // it was relative
}
div#menutop {
position: relative;
}

关于html - CSS3 搜索框响应,搜索按钮分解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34741592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com