特色栏目

ASP源码

PHP源码

.NET源码

JSP源码

游戏频道
专题合集
关闭菜单
首页> 文件数据> 如何在CSS中创建此形状? (垂直对齐div)

如何在CSS中创建此形状? (垂直对齐div)

时间:2026-01-19 13:00:03 作者:互联网
我如何在CSS中创建它?我无法对齐圆形div垂直中间.

见图:

这就是我所做的:https://jsfiddle.net/5odbwkn5/

.gray-btn1 {     width: 50px;     height: 50px;     -webkit-border-radius: 50%;     -moz-border-radius: 50%;     border-radius: 50%;     background: url(../images/ico/9.png) no-repeat center 70%;     background-color: #5dd6e4;     margin-left:-20px;     position: relative;     float:left; } .gray-btn {     width: 50px;     height: 50px;     -webkit-border-radius: 50%;     -moz-border-radius: 50%;     border-radius: 50%;     background: url(../images/ico/9.png) no-repeat center 70%;     background-color: #5dd6e4;     margin-right: -20px;     position: relative;     float:right; } .gray-mid {     background-color: #5dd6e4;     text-align:center; }
left
right
middle
你可以像之前和之后一样使用伪元素来轻松实现这种效果:

.container:before {    content:' ';    display:block;    height: 30px;    width:30px;    background-color:#999;    border-radius:15px;    position:absolute;    left:-15px;    top:7px;}.container:after {    content:' ';    display:block;    height: 30px;    width:30px;    background-color:#999;    border-radius:15px;    position:absolute;    right:-15px;    top:7px;}

这是我为你制作的FIDDLE作为例子.

编辑:我更新了小提琴,以确保圆圈(“之前”和“之后”)位于容器后面.并稍微移动元素,使其更符合您的图像.

相关文章

相关应用

热门文章

猜你喜欢

返回顶部