通过这样的Css样式就可以实现:
<div style="margin:0 autowidth:200px">
<input class="submit" id="btn" type="submit" value="注册" />
</div>
使用margin-left:automargin-right:auto可以让你的div居中对齐。
.style{margin-left:automargin-right:auto} 缩写形式为: .style{margin:0 auto} ,数字0 表示上下边距是0。
后面的那个width也是个很重要的属性,因为按钮的宽度非常小,所以要设置一个合适的width值才可以让按钮居中。
扩展资料
css中margin属性用法:
margin简写属性在一个声明中设置所有外边距属性。该属性可以有1到4个值。格式为-margin:10px 5px 15px 20px
实例:
1、margin:10px 5px 15px 20px
上边距是 10px,右边距是 5px,下边距是 15px,左边距是 20px;
2、margin:10px 5px 15px
上边距是 10px,右边距和左边距是 5px,下边距是 15px;
3、margin:10px 5px
上边距和下边距是 10px,右边距和左边距是 5px;
4、margin:10px
所有四个边距都是 10px。
在css中,主要通过border属性的设置,实现去掉边框。以代码编辑器:zend studio 10.0为例,可参考以下步骤去掉button(按钮)的边框:
1、新建一个html文件,命名为test.html,用于讲解。
2、在test.html文件内,使用button标签创建一个按钮,用于测试。
3、在test.html文件内,给button按钮添加一个id属性,用于样式的设置。
4、在test.html文件内,编写<style type="text/css"></style>标签,页面的css样式将写在该标签内。
5、在css标签中,通过id设置button的样式,定义其背景颜色为蓝色,文字颜色为白色,最后,将border属性设置为none,实现去掉button的边框。
6、在浏览器打开test.html文件,查看实现的效果。
需要准备的材料分别有:电脑、浏览器、html编辑器。
1、首先,打开html编辑器,新建html文件,例如:index.html。
2、在index.html中的<style>标签中,输入css代码:
button {border:0width: 200pxheight: 80pxbackground-color: gainsborocursor: not-allowed}
3、浏览器运行index.html页面,此时通过css实现了按钮的禁用样式。