html - 按钮和文本框的CSS

标签 html css

我想在布局中显示右侧的按钮和文本框。但现在我得到了这个链接。

enter image description here layout

   .search,
   .add {
     float: right;
     margin-left: 9px;
   }
   .sxt {
     float: right;
   }
<input class="stxt" type="text" name="searchtxt">
<a style="padding-right:2ex;"></a>
<button name="search" class="search">Search</button>

最佳答案

在你的 css 中做一些更改并像下面的代码一样更新它

 .search,.add{
 float: left;
margin-left: 9px;
background: #85BD02;
border: 0;
padding: 5px 10px;
border-radius: 5px;
color: white;
}

.sxt{
float: right;
}  
<div style="width: 50%;margin: auto;">
<input class="stxt" type="text" name="searchtxt">
<a style="padding-right:2ex;"></a><button name="search" class="search">Search</button>
    </div>

检查 jsfiddle:http://jsfiddle.net/2essewv0/2/

关于html - 按钮和文本框的CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28961326/

相关文章:

javascript - html5数据属性以文本形式显示

css - 无法使用 float :left and float:right 在父 div 内对齐 2 个子 div

html - 根据 JSON 值应用 CSS 样式

java - AngularJS、UI Bootsrap、MVC 前端 - data-ng-click 不起作用

html - 如何使用 gem htmltoword 在 Rails 中放置页眉和页脚?

html - 在彼此相邻的多个幻灯片中拆分 Bootstrap 的轮播幻灯片并更改箭头的可见性

Firefox 和 CSS3 动画 - 为什么我的文字摇摆不定?

javascript - Colorbox.js 内联内容不会显示

java - 如何将背景图像和 HTML 内容合并为一个可下载图像

javascript - 为什么当 Dev Console 启动时我在 Chrome 中获得更好的性能?