gpt4 book ai didi

html - 垂直和水平居中圆 Angular 矩形内的文本

转载 作者:太空宇宙 更新时间:2023-11-04 01:55:19 24 4
gpt4 key购买 nike

我希望圆 Angular 矩形内的文本居中(垂直和水平),并且还将此横幅在页面上居中,但不确定如何正确设置。其他元素也需要居中。请建议如何正确制作东西。这是代码:

#wrapper {
position: relative;
width: 80%;
margin: auto;
text-align: center;
vertical-align: middle;
}

#rcorners {
border-radius: 15px;
border: 6px solid #ffffff;
padding: 20px;
width: 450px;
height: 40px;
}

body {
background-image: url(images/blaunew.png);
background-color: #001b33;
color: #ffffff;
font-family: 'Roboto';
font-size: 14px;
}

#rcorners {
font-family: 'Roboto';
font-size: 48px;
font-weight: 700;
font-style: normal;
Helvetica,
sans-serif;
}

p {
font-family: 'Roboto';
font-size: 32px;
Helvetica,
sans-serif;
}

.main {
margin-top: 20%;
//font-size: 35px;
}

footer {
font-size: 14px;
}
<head>
<title>centered construction</title>
<link href='https://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'>

</head>

<body>
<div id="wrapper">
<div class="main">
<h1 id="rcorners">Centered Text No1</h1>
<p>LOREM IPSUM DOLOR </p>
</div>

<footer>
<div>&copy; Lorem Ipsum Dolor </div>
</footer>
</div>

最佳答案

#rcorners 中删除 width: 450px;height: 40px

否则,如果您想保持 450 像素宽,您可以将 margin: auto 添加到 #rcorners。它会解决您的问题。

@import url('https://fonts.googleapis.com/css?family=Roboto:400,700');

#wrapper {
position: relative;
width: 80%;
margin: auto;
text-align: center;
vertical-align: middle;
}

#rcorners {
border-radius: 15px;
border: 6px solid #ffffff;
padding: 20px;
/* width: 450px;
height: 40px; */
}
body {
background-image: url(images/blaunew.png);
background-color: #001b33;
color: #ffffff;
font-family: 'Roboto';font-size: 14px;
}
#rcorners {
font-family: 'Roboto';font-size:48px;font-weight:700; font-style:normal; Helvetica, sans-serif;
}
p {
font-family: 'Roboto'; font-size: 32px; Helvetica, sans-serif;
}

.main {
margin-top: 20%;
//font-size: 35px;
}

footer {
font-size: 14px;
}
<div id="wrapper">
<div class="main">
<h1 id="rcorners">Centered Text No1</h1>
<p>LOREM IPSUM DOLOR </p>
</div>

<footer>
<div>&copy; Lorem Ipsum Dolor </div>
</footer>
</div>

关于html - 垂直和水平居中圆 Angular 矩形内的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42762215/

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