原理是使用css3的渐变背景,再将高设为分割线的高度
<!DOCTYPE html><html><head><style>.title{ position:relative; text-align:center;}.title:before, .title:after { content: ""; width: 40%; height: 1px; position: absolute; top: 50%; }.title:before { background: -webkit-linear-gradient(right, #666 , #eee); background: -o-linear-gradient(left, #666 , #eee); background: -moz-linear-gradient(left,#666 , #eee); background: linear-gradient(to left, #666 , #eee); left: 2px;}.title:after { background: -webkit-linear-gradient(left, #666 , #eee); background: -o-linear-gradient(right, #666 , #eee); background: -moz-linear-gradient(right,#666 , #eee); background: linear-gradient(to right, #666 , #eee); right: 2px;}</style></head><body><p class="title">这是一个标题</p></body></html>效果图:
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号