【发布时间】:2025-04-16 19:45:01
【问题描述】:
我有一个链接,我尝试使用 text-align:center 和 display:inline-block 将其居中,但它似乎有点偏离中心。我在下面包含了图片和我的代码。任何帮助都会很棒,谢谢!给我带来麻烦的是在“按钮”类下
HTML:
<div class="headerContent">
<nav>
<ul class="navDown">
<li><a href="#">Intro</a></li>
<li><a href="#windSection">Wind</a></li>
<li><a href="#solarSection">Solar</a></li>
<li><a href="#nuclearSection">Nuclear</a></li>
<li><a href="#endSection">End</a></li>
</ul>
<a href="#" class="menu-icon"><p class="menu"></p></a>
</nav>
<a href="#" class="scrollup">Scroll</a>
<a href="#windSection" class="scrolldown">Scroll</a>
<h1 class="title bigTitle">Going Green.</h1>
<p class="headerText">
A change is coming- and that change will be making the switch to green forms of energy. If you are interested in learning how you can help the environment and save money over time- you have come to the right place. It is time to Energize Change. <br><span class="emphasis">Click below to find the perfect green energy source for you and your family!</span>
</p>
<p class= "noElechouse"></p>
<div class="select">
<a class="button" href="links/calculator.html">Find Now</a>
</div>
</div>
CSS:
.headerContent {
position:relative;
width:55%;
margin:auto;
height:100%;
text-align:center;
}
.title {
font-family: 'Oxygen', sans-serif;
font-weight:700;
color:white;
font-size:90px;
padding-bottom:15px;
padding-top:15px;
}
.headerText {
position:absolute;
bottom:35%;
font-family: 'Oxygen', sans-serif;
font-weight:400;
font-size:18px;
line-height:27px;
width:90%;
margin:auto;
display:block;
left:0;
right:0;
}
.select {
text-align:center;
}
.button {
position:absolute;
display:inline-block;
font-family: 'Oxygen', sans-serif;
font-weight:normal;
font-size:30px;
color:white;
bottom:10px;
text-decoration:none;
padding: 10px 20px;
}
【问题讨论】:
-
你能在 jsfiddle.net 上发布一个孤立的样本吗?
标签: html centering css text-alignment