CSS去掉div的边框可以去掉css的border属性,或者覆盖border属性为none来实现。
1、如图,这是一个带边框的div测是页面。
2、第一个div的边框是这行css实现的效果
border: 5px solid black
3、第二个div没有设置边框样式
4、第三个div的css设置了边框样式,但被内联样式覆盖为none,因此也能不显示边框。
代码如下
<div class="box1"></div>
<div class="box2"></div>
<div class="box3" style="border: none"></div>
div{
width:200px
height:120px
margin-bottom:10px
background-color:yellow
}
.box1, .box3{
border: 5px solid black
}
在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文件,查看实现的效果。
消除边框的有几种,如下:
此为消除标签元素自带的一些边距:
margin:0 padding:0此为消除标签元素自带的一些边线:
border:noneborder-left:none//消除左边线
border-right:none//消除右边线
border-top:none//消除上边线
border-bottom:none//消除下边线
像图片中的样式要利用层级关系,让大框在小框下面被遮挡,再消除小框架的右边线:
.a{ width:100px height:100px background-color:#eee position:relative border:1px solid #ff0707 border-right:none margin-top:300px }.b{ width:300px height:300px z-index:-1 background-color:#eee position:absolute left:99px top:-100px border:1px solid #ff0707 }