【发布时间】:2022-01-26 03:28:02
【问题描述】:
我遇到了一个问题,我无法让图标正确对齐。如果我删除所有图标的部分,徽标和标题会完美对齐,但是在添加图标时会导致大量问题。抱歉,如果这是一个愚蠢的问题,html 对我来说是新的!
我正在为设计元素使用基本 HTML5 模板:HTML5UP Editorial
HTML 和 CSS:
/* Header */
#header {
display: -moz-flex;
display: -webkit-flex;
display: -ms-flex;
display: flex;
border-bottom: solid 5px #f56a6a;
padding: 6em 0 1em 0;
position: relative; }
#header > * {
-moz-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
margin-bottom: 0; }
#header .logo {
border-bottom: 0;
color: inherit;
font-family: "Roboto Slab", serif;
font-size: 1.125em; }
#header .icons {
text-align: right; }
@media screen and (max-width: 1680px) {
#header {
padding-top: 5em; } }
@media screen and (max-width: 736px) {
#header {
padding-top: 6.5em; }
#header .logo {
font-size: 1.25em;
margin: 0; }
#header .icons {
height: 5em;
line-height: 5em;
position: absolute;
right: -0.5em;
top: 0; } }
/* Icons */
ul.icons {
cursor: default;
list-style: none;
padding-left: 0; }
ul.icons li {
display: inline-block;
padding: 0 1em 0 0; }
ul.icons li:last-child {
padding-right: 0; }
ul.icons li .icon {
color: inherit; }
ul.icons li .icon:before {
font-size: 1.25em; }
<!-- Header -->
<header id="header">
<div>
<a href="index.php" class="logo"><img style="vertical-align:middle; margin-right:0.5em;"; src="images/cat-logo.png"; alt=""; width="64"; height="64";/></a>
<a class="logo"><strong> Oscat Pets</strong></a>
<ul class="icons">
<li><a href="#" class="icon brands fa-facebook-f"><span class="label">Facebook</span></a></li>
<li><a href="#" class="icon brands fa-twitter"><span class="label">Twitter</span></a></li>
<li><a href="#" class="icon brands fa-instagram"><span class="label">Instagram</span></a></li>
<li><a href="#" class="icon brands fa-snapchat-ghost"><span class="label">Snapchat</span></a></li>
<li><a href="#" class="icon brands fa-medium-m"><span class="label">Medium</span></a></li>
</ul>
</div>
</header>
Example of Current Broken Alignment
Example of how Alignment should look
【问题讨论】:
-
能否在 sn-p 中包含当前“损坏”的 CSS,没有它,html 没有多大用处
-
嗨@Raxi,我希望我已经包含了正确的内容!由于我使用模板工作,我仍在学习我在做什么的来龙去脉!
-
是你使用的模板的css和你自己的修改吗?
position的属性尤其显得格格不入? -
这是原始模板中所有未修改的代码(在 main.css 中) 在我添加图像之前使用模板时它工作正常!添加图像使我不得不对齐“Oscat Pets”部分,该部分现在工作正常。它只是迫使它不起作用的图标!
-
是的,我明白了,我在下面的答案之一中添加了一个有效的修复程序。
标签: html alignment vertical-alignment