css怎么实现竖线


本文摘自PHP中文网,作者青灯夜游,侵删。

实现方法:1、利用border-left或border-right属性实现;2、使用伪元素来实现;3、利用box-shadow属性实现;4、利用“filter:drop-shadow()”实现;5、利用linearGradient渐变实现。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

css实现竖线的方法

html:

1

<p class="p1">实现竖线</p>

css:

1

2

3

4

5

6

7

8

p{

        width: 200px;

        height: 50px;

        line-height:50px;

        text-align: center;

        background: #ccc;

        position: relative;

  }

方法一:使用border-left或者border-right

1

2

3

4

.p1 {

    border-left: 5px solid red;

    border-right: 5px solid red;

}

效果图:

1.png

方法二:使用伪元素来实现

每个标签都会有before及after两个伪元素,并且我们也经常用这类标签做一些Icon之类的小图标。这里我们使用伪元素,也会很容易来实现想要的效果。

1

2

3

4

5

6

7

8

9

.p1::before {

        content: "";

        width: 5px;

        height:50px;

        position: absolute;

        top: 0;

        left: 0;

        background: red;

}

效果图:

阅读剩余部分

相关阅读 >>

使用html+css制作一些动画提示工具

css怎么实现平方

css怎么取消颜色

css中怎么设置背景图

css字体大小如何设置

css怎么让一段缩进

前端怎么学

css如何禁止滑动

详解纯css实现文字渐变色的两种方式

css中float属性的属性值有哪些

更多相关阅读请进入《css》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...