html - 使用响应式设计搜索...宽度 100%?

标签 html css responsive-design media-queries search-engine

我正在尝试设计一个响应式设计的搜索引擎,但当窗口长度减小时,我的搜索按钮和文本框出现问题。我不知道我是否可以帮助我。我希望文本框和按钮一起占据我容器的 100%

这是我想出的: https://jsfiddle.net/wfbchc1y/

.mainBox{
	max-width: 800px;
	box-sizing: border-box;
	border: solid 1px #D5D4D4;
	background-color: #FFF;
	margin:0 auto;
	padding:20px;
}
#txtSearch{
	height: 40px;
	margin-right: 10px;
	border: solid 1px #CBCBCB;
	border-radius: 4px;
	outline: none;
	box-sizing: border-box;
	padding: 10px;
	color: #6D6A6A;
	width: 92%;
	float: left;
}

#btnSearch{
	box-sizing: border-box;
	height: 40px;
	padding: 10px 15px;
	border-radius: 4px;
	outline:none;
	cursor:pointer;
	transition:All .5s ease;
	border:solid 1px #000;
	background-color:#009;
	color:white;
}
 <div class="mainBox">
  <input type="text" name="peticion" placeholder="Search" id="txtSearch">
  <input type="button" value=">" id="btnSearch">
 </div>

最佳答案

您可以使用 css calc计算输入的宽度。

width: calc(92% - 40px);//92% - width of input

Jsfiddle

关于html - 使用响应式设计搜索...宽度 100%?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34379875/

相关文章:

javascript - Bootstrap 折叠菜单链接在移动设备上不起作用

html - 避免响应页面的重复内容

android - 网站页脚在我的移动设备上不稳定

html - 将两个 div 并排放置,如果空间足够则居中

html - 添加链接到按钮 HTML

javascript - 使用javascript更改不同形状的颜色

javascript - 检查 DOM 元素是否可以与之交互

jquery - html表格分页+复选框显示过滤器

html - bootstrap 复选框和标签在同一行

javascript - 图像输入按钮时提交的 HTML javascript 表单