如何使用CSS画一个空心长方形 要代码哦,是使用DIV+CSS

html-css012

如何使用CSS画一个空心长方形 要代码哦,是使用DIV+CSS,第1张

如果你只要一条垂直线就设置这个DIV的边框线样式就可以了,样式代码:border-left:1px #000000 solid 这里的border-left是指这个DIV的左边边框,1px就是线的宽度,#000000是线的颜色(这里是黑色),solid是线的样式(这里是实线),整个DIV的代码可以这样写:<div style="width:200pxheight:500pxborder-left:1px #000000 solid"></div>

5、上三角

最终效果:

CSS代码如下:

复制代码

代码如下:

#triangle-up {

width: 0

height: 0

border-left: 50px solid transparent

border-right: 50px solid transparent

border-bottom: 100px solid red

}

6、下三角

最终效果:

CSS代码如下:

复制代码

代码如下:

#triangle-down {

width: 0

height: 0

border-left: 50px solid transparent

border-right: 50px solid transparent

border-top: 100px solid red

}

7、左三角

最终效果:

CSS代码如下:

复制代码

代码如下:

#triangle-left {

width: 0

height: 0

border-top: 50px solid transparent

border-right: 100px solid red

border-bottom: 50px solid transparent

}

8、右三角

最终效果:

CSS代码如下:

复制代码

代码如下:

#triangle-right {

width: 0

height: 0

border-top: 50px solid transparent

border-left: 100px solid red

border-bottom: 50px solid transparent

}

9、左上三角

最终效果:

CSS代码如下:

复制代码

代码如下:

#triangle-topleft {

width: 0

height: 0

border-top: 100px solid red

border-right: 100px solid transparent

}

10、右上三角

最终效果:

CSS代码如下:

复制代码

代码如下:

#triangle-topright {

width: 0

height: 0

border-top: 100px solid red

border-left: 100px solid transparent

}

11、左下三角

最终效果:

CSS代码如下:

复制代码

代码如下:

#triangle-bottomleft {

width: 0

height: 0

border-bottom: 100px solid red

border-right: 100px solid transparent

}

12、右下三角

最终效果:

CSS代码如下:

复制代码

代码如下:

#triangle-bottomright {

width: 0

height: 0

border-bottom: 100px solid red

border-left: 100px solid transparent

}

13、平行四边形

1、首先新建一个html文件,命名为test.html。

2、在test.html文件内,使用div标签一个模块,在div内,再使用div标签创建两个内部模块,下面将让两个内部div并排显示。

3、在test.html文件内,分别给每一个div设置class属性,分别为wdiv,fldiv,frdiv。

4、在css标签内,设置class为wdiv的div样式,定义其宽度为500px,高度为400px,背景颜色为灰色。

5、在css标签内,再分别设置class为fldiv和frdiv的样式,定义它们的宽度为240px,高度为350px,同时,使用float属性分别设置一个div浮动向左,另一个浮动向右,从而实现并排显示。

6、最后在浏览器打开test.html文件,查看实现的效果,就完成了。