我试图模仿苹果的导航栏风格,特别是CSS3扩展搜索领域的风格。
它使用一个带有display:table的UL,它是带有display:table-cell和width:100%的LI。当搜索聚焦时,李的搜索范围扩大了,另一个李的合同也适合了。
现在我的li不能调整大小了。
有没有人知道我错过了什么?
而且,IE甚至没有显示任何内容。
发布于 2012-07-03 15:37:06
嘿,现在你可以用这个了
HTML
<input type="text" placeholder="search bar">css
input[type="text"] {
background: #444;
border: 0 none;
font: bold 12px Arial,Helvetica,Sans-serif;
color: #d7d7d7;
width:50px;
padding: 6px 15px 6px 35px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
text-shadow: 0 2px 2px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 3px rgba(0, 0, 0, 0.2) inset;
margin:3px 12px;
}
input[type="text"]:focus {
background:#fcfcfc;
color: #6a6f75;
width: 120px;
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(0, 0, 0, 0.9) inset;
text-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
margin:3px 12px;
outline: none;
}
input[type="text"] {
-webkit-transition: all 0.7s ease 0s;
-moz-transition: all 0.7s ease 0s;
-o-transition: all 0.7s ease 0s;
transition: all 0.7s ease 0s;
}实时演示http://jsfiddle.net/vzLFS/3/
发布于 2012-07-03 17:40:42
在苹果页面上,当输入获得焦点时,他们似乎会在nav-element (.searchmode)中添加一个类,用于处理包含<input>的<li>-element的宽度。
虽然不确定是否有一个只有css的解决方案,但你可以像这样用jQuery做一些事情:
$('#searchform input').on('focus', function(){
$(this).closest('li').css('width', '180px');
});
$('#searchform input').on('blur', function(){
$(this).closest('li').css('width', '50px');
});...and仍然对FX使用css-transitions :)
https://stackoverflow.com/questions/11305406
复制相似问题