这么用CSS生成漂亮的水平分隔线(horizontal rule)设计效果 - css笔记

我们常常使用hr标签来生成水平分隔线 ,但默认的水平分割线不够特色,接下来,就分享一些有趣的水平分割线

HTML代码中, 我们常常使用<hr/>标签来生成水平分隔线 ,但默认的水平分割线不够特色,接下来,就分享一些有趣的水平分割线。

  • 原文来源:详情
  • 效果演示:页底

这么用CSS生成漂亮的水平分隔线(horizontal rule)设计效果 - css笔记

相关CSS代码

/* 渐变 color1 - color2 - color1 */

hr.style-one {
    border: 0;
    height: 1px;
    background: #333;
    background-image: linear-gradient(to right, #ccc, #333, #ccc);
}

/* 透明渐变 - color - transparent */

hr.style-two {
    border: 0;
    height: 1px;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}

/* 双线 */

hr.style-three {
    border: 0;
    border-bottom: 1px dashed #ccc;
    background: #999;
}

/* 单线阴影 */

hr.style-four {
    height: 12px;
    border: 0;
    box-shadow: inset 0 12px 12px -12px rgba(0, 0, 0, 0.5);
}

/* 云朵状 */

hr.style-five {
    border: 0;
    height: 0; /* Firefox... */box-shadow: 0 0 10px 1px black;
}
hr.style-five:after {  /* Not really supposed to work, but does */content: "
/* 渐变 color1 - color2 - color1 */
hr.style-one {
border: 0;
height: 1px;
background: #333;
background-image: linear-gradient(to right, #ccc, #333, #ccc);
}
/* 透明渐变 - color - transparent */
hr.style-two {
border: 0;
height: 1px;
background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}
/* 双线 */
hr.style-three {
border: 0;
border-bottom: 1px dashed #ccc;
background: #999;
}
/* 单线阴影 */
hr.style-four {
height: 12px;
border: 0;
box-shadow: inset 0 12px 12px -12px rgba(0, 0, 0, 0.5);
}
/* 云朵状 */
hr.style-five {
border: 0;
height: 0; /* Firefox... */box-shadow: 0 0 10px 1px black;
}
hr.style-five:after {  /* Not really supposed to work, but does */content: "\00a0";  /* Prevent margin collapse */
}
/* 内嵌 */
hr.style-six {
border: 0;
height: 0;
border-top: 1px solid rgba(0, 0, 0, 0.1);
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}
/* 晕状 */
hr.style-seven {
height: 30px;
border-style: solid;
border-color: black;
border-width: 1px 0 0 0;
border-radius: 20px;
}
hr.style-seven:before { 
display: block;
content: "";
height: 30px;
margin-top: -31px;
border-style: solid;
border-color: black;
border-width: 0 0 1px 0;
border-radius: 20px;
}
/* 文字插入式 */
hr.style-eight {
padding: 0;
border: none;
border-top: medium double #333;
color: #333;
text-align: center;
}
hr.style-eight:after {
content: "gb";
display: inline-block;
position: relative;
top: -0.7em;
font-size: 1.5em;
padding: 0 0.25em;
background: white;
}
/* 分隔线统一样式 */
hr{
margin: 40px 0;
}
a0"; /* Prevent margin collapse */ } /* 内嵌 */ hr.style-six { border: 0; height: 0; border-top: 1px solid rgba(0, 0, 0, 0.1); border-bottom: 1px solid rgba(255, 255, 255, 0.3); } /* 晕状 */ hr.style-seven { height: 30px; border-style: solid; border-color: black; border-width: 1px 0 0 0; border-radius: 20px; } hr.style-seven:before { display: block; content: ""; height: 30px; margin-top: -31px; border-style: solid; border-color: black; border-width: 0 0 1px 0; border-radius: 20px; } /* 文字插入式 */ hr.style-eight { padding: 0; border: none; border-top: medium double #333; color: #333; text-align: center; } hr.style-eight:after { content: "gb"; display: inline-block; position: relative; top: -0.7em; font-size: 1.5em; padding: 0 0.25em; background: white; } /* 分隔线统一样式 */ hr{ margin: 40px 0; }

html 水平线中间添加文字

上文中的方法已经失效,参考这篇文章:

感觉这篇文章写的好复杂,可以参考本站的登录框是咋实现的,好像是用CSS顶上去,再给背景填充颜色。

她的部落
下载权限
查看
  • 免费下载
    评论并刷新后下载
    登录后下载
  • {{attr.name}}:
您当前的等级为
登录后免费下载登录 小黑屋反思中,不准下载! 评论后刷新页面下载评论 支付以后下载 请先登录 您今天的下载次数(次)用完了,请明天再来 支付积分以后下载立即支付 支付以后下载立即支付 您当前的用户组不允许下载升级会员
您已获得下载权限 您可以每天下载资源次,今日剩余

给TA赞赏
共{{data.count}}人
人已赞赏
⚠️
Npcink上的部份代码及教程来源于互联网,仅供网友学习交流,若您喜欢本文可附上原文链接随意转载。
无意侵害您的权益,请发送邮件至 1355471563#qq.com 或点击右侧 私信:Muze 反馈,我们将尽快处理。
购物车
优惠劵
搜索