我的头衔不会居中。正如你所看到的,副标题是可以的,但是标题更靠左。我该如何解决这个问题呢?网站链接:http://st358373.cmd16c.cmi.hanze.nl/portfolio.html
HTML:
<div class="titel">Portfolio</div>
<div class="subtitel">Hier is een selectie van recentelijk werk.</div>CSS:
.titel {
font-family: Raleway;
font-size: 52px;
color: #3b3d40;
text-align: center;
font-weight: 700;
margin-top: 20px;
display: block;
}
.subtitel {
font-family: Adobe Caslon Pro;
font-size: 18px;
text-align: center;
margin-top: 40px;
margin-bottom: 50px;
}发布于 2017-01-17 03:38:05
你的网站的问题是你的社交图标漂浮在右边。因此,您需要做的是清除标题容器。为此,您需要做的就是为.titel添加clear: right;
有关参考信息,请查看MDN documentation on the clear property
发布于 2017-09-29 02:04:18
.titel {
font-family: Raleway;
font-size: 52px;
color: #3b3d40;
}
.subtitel {
font-family: Adobe Caslon Pro;
font-size: 18px;
}
.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%); /* IE 9 */
-webkit-transform: translate(-50%, -50%); /* Chrome, Safari, Opera */
text-align: center;
}<body>
<div class="center">
<div class="titel">Portfolio</div>
<div class="subtitel">Hier is een selectie van recentelijk werk.</div>
</div>
</body>
发布于 2017-01-17 03:37:36
基本上,这应该会像预期的那样工作,看看snippet:
.titel {
font-family: Raleway;
font-size: 52px;
color: #3b3d40;
text-align: center;
font-weight: 700;
margin-top: 20px;
display: block;
}
.subtitel {
font-family: Adobe Caslon Pro;
font-size: 18px;
text-align: center;
margin-top: 40px;
margin-bottom: 50px;
}<div class="titel">Portfolio</div>
<div class="subtitel">Hier is een selectie van recentelijk werk.</div>
您还可以尝试使用.titel,如下所示:
display: inline-block;
width: 100%;另一种方法是在.social目录下添加<div style="clear:both"></div>。
https://stackoverflow.com/questions/41683763
复制相似问题