【问题标题】:the logo name in the headmenu of my site is passing through [duplicate]我网站标题菜单中的徽标名称正在通过[重复]
【发布时间】:2020-05-25 07:42:26
【问题描述】:

我试图将名称置于我网站上徽标名称和 ID 的头部、顶部和底部的中心。 我曾尝试使用 margin top,它有点工作,但它并不是我想要的。

Desired output

此外,我正在尝试将徽标名称设为 href 以链接到主页/首页。

代码sn-p:

body {
    background: #ebe7e7;
}

@font-face {
    font-family: liant;
    src: url(liant_regular-webfont.woff);

}
#lineup {
    background-color: rgb(73, 35, 35);
    width: 100%;
    height: 5px;
    position:fixed;
    left: 0px; right: 0px; top: 0px;
}

#head {
    background-color: #cccccc;
    color: rgb(141, 68, 40);    
    width: 100%;
    height: 60px;
    position: fixed;
    left: 0px; right: 0px; top: 5px;
}

#logotxt {
    text-align: center;
    font-family: liant;
    font-size: 40px;
    font-weight: 800;
   
}

#linedown {
    background-color: rgb(73, 35, 35);
    width: 100%;
    height: 5px;
    position:fixed;
    left: 0px; right: 0px; top: 65px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Viveka Yoga</title>
    <link rel="stylesheet" href="yoga.css">
</head>
<body>
    <div id ="lineup"></div>
    <div id="head">
        <p id="logotxt">Viveka Yoga</p>
    </div>
    <div id="linedown"></div>
    <script src="yoga.js"></script>
</body>
</html>

【问题讨论】:

  • 将以下css添加到&lt;p&gt;标签:margin: 0; height: 100%; line-height: 60px;

标签: html css


【解决方案1】:

利用弹性盒子。

查看#head的样式

body {
    background: #ebe7e7;
}

@font-face {
    font-family: liant;
    src: url(liant_regular-webfont.woff);

}
#lineup {
    background-color: rgb(73, 35, 35);
    width: 100%;
    height: 5px;
    position:fixed;
    left: 0px; right: 0px; top: 0px;
}

#head {
    background-color: #cccccc;  
    width: 100%;
    height: 60px;
    position: fixed;
    left: 0px; right: 0px; top: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#logotxt {
    text-align: center;
    font-family: liant;
    font-size: 40px;
    font-weight: 800;
    text-decoration: none;
    color: rgb(141, 68, 40);  
}

#linedown {
    background-color: rgb(73, 35, 35);
    width: 100%;
    height: 5px;
    position:fixed;
    left: 0px; right: 0px; top: 65px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Viveka Yoga</title>
    <link rel="stylesheet" href="yoga.css">
</head>
<body>
    <div id ="lineup"></div>
    <div id="head">
        <a href="/" id="logotxt">Viveka Yoga</a>
    </div>
    <div id="linedown"></div>
    <script src="yoga.js"></script>
</body>
</html>

【讨论】:

  • @manin yw 刚刚编辑并将&lt;p&gt; 替换为&lt;a&gt; 作为您的主播。如果它解决了您的问题,请接受答案。干杯
  • 您能否稍微解释一下为什么将

    更改为 ,但无论如何感谢您的帮助!

  • @manin 锚只是你的链接(href)到主页/ 或用你主页所在的网址复制/
猜你喜欢
  • 2021-06-29
  • 1970-01-01
  • 2019-06-04
  • 1970-01-01
  • 2012-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-20
相关资源
最近更新 更多