gpt4 book ai didi

HTML/CSS - 并排重叠的圆圈

转载 作者:太空宇宙 更新时间:2023-11-04 00:51:02 25 4
gpt4 key购买 nike

我正在尝试制作 4 个重叠的圆圈,每个圆圈的中间都有居中文本(类似于 PowerPoint SmartArt)。我找到了一个 example在线并能够修改它使圆圈并排,但是文本仍然没有正确对齐:

https://codepen.io/anon/pen/vMwEZz

.venn-container {
padding: 25px 25px 25px 200px;
}
.venncircle {
padding: 18px;
width: 180px;
height: 180px;
-moz-border-radius: 200px;
-webkit-border-radius: 200px;
border-radius: 50%;
position: absolute;
-webkit-transition: color 0.5s linear, background-color 0.5s linear;
-moz-transition: color 0.5s linear, background-color 0.5s linear;
-o-transition: color 0.5s linear, background-color 0.5s linear;
transition: color 0.5s linear, background-color 0.5s linear;
}
.venncircle > a {
font-size: 19px;
font-weight: bold;
letter-spacing: .004em;
color: #FFFFFF;
text-decoration: none;
}
.venncirctop {
padding: 18px;
width: 180px;
height: 180px;
-moz-border-radius: 200px;
-webkit-border-radius: 200px;
border-radius: 50%;
position: absolute;
-webkit-transition: color 0.5s linear, background-color 0.5s linear;
-moz-transition: color 0.5s linear, background-color 0.5s linear;
-o-transition: color 0.5s linear, background-color 0.5s linear;
transition: color 0.5s linear, background-color 0.5s linear;
margin-bottom: -210px;
margin-left: 20px;
background-color: #5c5b59;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(92, 91, 89, 0.5);
z-index: 1;
position: relative;
}
.venncirctop > a {
font-size: 19px;
font-weight: bold;
letter-spacing: .004em;
color: #FFFFFF;
text-decoration: none;
}
.venncirctop:hover {
z-index: 5;
background-color: #6A6561;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(106, 101, 97, 0.9);
}
.venncirclft {
padding: 18px;
width: 180px;
height: 180px;
-moz-border-radius: 200px;
-webkit-border-radius: 200px;
border-radius: 50%;
position: absolute;
-webkit-transition: color 0.5s linear, background-color 0.5s linear;
-moz-transition: color 0.5s linear, background-color 0.5s linear;
-o-transition: color 0.5s linear, background-color 0.5s linear;
transition: color 0.5s linear, background-color 0.5s linear;
margin-left: -157px;
background-color: #093d5c;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(9, 61, 92, 0.5);
z-index: 2;
}
.venncirclft > a {
font-size: 19px;
font-weight: bold;
letter-spacing: .004em;
color: #FFFFFF;
text-decoration: none;
}
.venncirclft:hover {
z-index: 5;
background-color: #37688C;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(55, 104, 140, 0.9);
}
.venncircrt {
padding: 18px;
width: 180px;
height: 180px;
-moz-border-radius: 200px;
-webkit-border-radius: 200px;
border-radius: 50%;
position: absolute;
-webkit-transition: color 0.5s linear, background-color 0.5s linear;
-moz-transition: color 0.5s linear, background-color 0.5s linear;
-o-transition: color 0.5s linear, background-color 0.5s linear;
transition: color 0.5s linear, background-color 0.5s linear;
margin-left: 200px;
background-color: #5e577b;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(94, 87, 123, 0.5);
z-index: 3;
text-align: right;
}
.venncircrt > a {
font-size: 19px;
font-weight: bold;
letter-spacing: .004em;
color: #FFFFFF;
text-decoration: none;
}
.venncircrt:hover {
z-index: 5;
background-color: #625F75;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(98, 95, 117, 0.9);
}
.venncircbtm {
padding: 18px;
width: 180px;
height: 180px;
-moz-border-radius: 200px;
-webkit-border-radius: 200px;
border-radius: 50%;
position: absolute;
-webkit-transition: color 0.5s linear, background-color 0.5s linear;
-moz-transition: color 0.5s linear, background-color 0.5s linear;
-o-transition: color 0.5s linear, background-color 0.5s linear;
transition: color 0.5s linear, background-color 0.5s linear;
top: 0px;
margin-right: 100px;
margin-left: 390px;
text-align: center;
background-color: #627746;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(98, 119, 70, 0.5);
z-index: 1;
position: relative;
}
.venncircbtm > a {
font-size: 19px;
font-weight: bold;
letter-spacing: .004em;
color: #FFFFFF;
text-decoration: none;
}
.venncircbtm:hover {
z-index: 5;
background-color: #3a4e20;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(58, 78, 32, 0.9);
}
.venntxttop {
text-align: center;
display: inline-block;
margin: 0 auto;
position: relative;
top: 10px;
}
.venntxttop:hover {
color: #FFFFFF;
text-decoration:none;
}
.venntxtrt {
margin: 0 0 0 87px;
display: inline-block;
position: relative;
top: 63px;
z-index: 5;
}
.venntxtrt:hover {
color: #FFFFFF;
text-decoration:none;
}

.venntxtlft {
width: 70%;
display: inline-block;
position: relative;
top: 63px;
z-index: 5;
}
.venntxtlft:hover {
color: #FFFFFF;
text-decoration:none;
}
.venntxtbtm {
text-align: center;
display: inline-block;
width: 70%;
position: relative;
top: 103px;
}
.venntxtbtm:hover {
color: #FFFFFF;
text-decoration:none;
}

我会继续调试,但感谢任何帮助/指针对齐文本中心。

最佳答案

在没有 position:absolute 的情况下更新您的代码,使用 margin-left:-45px 并使用文本垂直和水平居中

.venn-container a {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}

.venn-container {
padding: 10px;
}
.venn-container > div{
float:left;
position: relative;
}
.venncircle {
padding: 18px;
width: 180px;
height: 180px;
-moz-border-radius: 200px;
-webkit-border-radius: 200px;
border-radius: 50%;
position: absolute;
-webkit-transition: color 0.5s linear, background-color 0.5s linear;
-moz-transition: color 0.5s linear, background-color 0.5s linear;
-o-transition: color 0.5s linear, background-color 0.5s linear;
transition: color 0.5s linear, background-color 0.5s linear;
}
.venncircle > a {
font-size: 19px;
font-weight: bold;
letter-spacing: .004em;
color: #FFFFFF;
text-decoration: none;
}
.venncirctop {
padding: 18px;
width: 180px;
height: 180px;
-moz-border-radius: 200px;
-webkit-border-radius: 200px;
border-radius: 50%;
-webkit-transition: color 0.5s linear, background-color 0.5s linear;
-moz-transition: color 0.5s linear, background-color 0.5s linear;
-o-transition: color 0.5s linear, background-color 0.5s linear;
transition: color 0.5s linear, background-color 0.5s linear;
background-color: #5c5b59;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(92, 91, 89, 0.5);
z-index: 2;
margin-left:-45px;
}
.venncirctop > a {
font-size: 19px;
font-weight: bold;
letter-spacing: .004em;
color: #FFFFFF;
text-decoration: none;
}
.venncirctop:hover {
z-index: 5;
background-color: #6A6561;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(106, 101, 97, 0.9);
}
.venncirclft {
padding: 18px;
width: 180px;
height: 180px;
-moz-border-radius: 200px;
-webkit-border-radius: 200px;
border-radius: 50%;
-webkit-transition: color 0.5s linear, background-color 0.5s linear;
-moz-transition: color 0.5s linear, background-color 0.5s linear;
-o-transition: color 0.5s linear, background-color 0.5s linear;
transition: color 0.5s linear, background-color 0.5s linear;
background-color: #093d5c;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(9, 61, 92, 0.5);
z-index: 1;
}
.venncirclft > a {
font-size: 19px;
font-weight: bold;
letter-spacing: .004em;
color: #FFFFFF;
text-decoration: none;
}
.venncirclft:hover {
z-index: 5;
background-color: #37688C;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(55, 104, 140, 0.9);
}
.venncircrt {
padding: 18px;
width: 180px;
height: 180px;
-moz-border-radius: 200px;
-webkit-border-radius: 200px;
border-radius: 50%;
-webkit-transition: color 0.5s linear, background-color 0.5s linear;
-moz-transition: color 0.5s linear, background-color 0.5s linear;
-o-transition: color 0.5s linear, background-color 0.5s linear;
transition: color 0.5s linear, background-color 0.5s linear;
background-color: #5e577b;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(94, 87, 123, 0.5);
z-index: 3;
margin-left:-45px;
}
.venncircrt > a {
font-size: 19px;
font-weight: bold;
letter-spacing: .004em;
color: #FFFFFF;
text-decoration: none;
}
.venncircrt:hover {
z-index: 5;
background-color: #625F75;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(98, 95, 117, 0.9);
}
.venncircbtm {
padding: 18px;
width: 180px;
height: 180px;
-moz-border-radius: 200px;
-webkit-border-radius: 200px;
border-radius: 50%;
position: absolute;
-webkit-transition: color 0.5s linear, background-color 0.5s linear;
-moz-transition: color 0.5s linear, background-color 0.5s linear;
-o-transition: color 0.5s linear, background-color 0.5s linear;
transition: color 0.5s linear, background-color 0.5s linear;
top: 0px;
text-align: center;
background-color: #627746;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(98, 119, 70, 0.5);
z-index: 4;
margin-left:-45px;
}
.venncircbtm > a {
font-size: 19px;
font-weight: bold;
letter-spacing: .004em;
color: #FFFFFF;
text-decoration: none;
}
.venncircbtm:hover {
z-index: 5;
background-color: #3a4e20;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
background-color: rgba(58, 78, 32, 0.9);
}
.venn-container a {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.venntxttop:hover {
color: #FFFFFF;
text-decoration:none;
}
.venntxtrt:hover {
color: #FFFFFF;
text-decoration:none;
}
.venntxtlft:hover {
color: #FFFFFF;
text-decoration:none;
}
.venntxtbtm:hover {
color: #FFFFFF;
text-decoration:none;
}
<link href="//netdna.bootstrapcdn.com/bootstrap/2.3.1/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<link href="//netdna.bootstrapcdn.com/bootstrap/2.3.1/css/bootstrap-responsive.min.css" rel="stylesheet" />

<div class="row-fluid">
<div class="span12">
<div class="venn-container">
<div class="venncirclft">
<a class="venntxtlft" href="#">Left</a>
</div>
<div class="venncirctop">
<a class="venntxttop" href="#">Top</a>
</div>
<div class="venncircrt">
<a class="venntxtrt" href="#">Right</a>
</div>
<div class="venncircbtm">
<a class="venntxtbtm" href="#">Bottom</a>
</div>
</div>
</div>
</div>

关于HTML/CSS - 并排重叠的圆圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55917279/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com