首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为我的网页制作页眉[HTML5,CSS3]

如何为我的网页制作页眉[HTML5,CSS3]
EN

Stack Overflow用户
提问于 2020-10-17 17:19:32
回答 2查看 86关注 0票数 0

我正在尝试为我的网站做一个标题,我希望它看起来像这样。The header I want to create

但我不确定什么是最好的方式来使标志看起来像那样。

我试过了,

代码语言:javascript
复制
.logo {
  height: 130px;
  width: 130px;
  cursor: pointer;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -18px;
}

#circle {
  border-radius: 50%;
  width: 80px;
  height: 80px;
  background-color: white;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -1px;
  -webkit-box-shadow: 0px 3px 15px rgba(100, 100, 100, 0.49);
  -moz-box-shadow: 0px 3px 15px rgba(100, 100, 100, 0.49);
  box-shadow: 0px 3px 15px rgba(100, 100, 100, 0.49);
}

#rect {
  width: 120px;
  height: 65px;
  background-color: white;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -1px;
}
代码语言:javascript
复制
<header>

  <div id="circle"></div>
  <div id="rect"></div>
  <img src="img/MU-logo.png" alt="Madridismo" class="logo">

  <nav>
    <ul class="nav_links">
      <li><a href="index.html">Home</a></li>
      <li><a href="index.html">Games</a></li>
    </ul>
  </nav>

  <div id="clock"></div>

</header>

但我仍然在寻找正确的方法来做到这一点。还有谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-10-17 23:15:22

这应该可以让你开始学习了。您需要添加正确的字体和颜色。

代码语言:javascript
复制
<header>
  <nav>
    <ul class="nav_links">
      <li><a href="index.html">Home</a></li>
      <li><a href="index.html">Games</a></li>
    </ul>
  </nav>
 
  <div class="center-circle">
     <img src="img/MU-logo.png" alt="Madridismo" class="logo">
  </div>
  <div class="clock" id="clock"></div>

</header>
代码语言:javascript
复制
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background: #999;
}

header {
  position: relative;
  display: flex;
  width: 100%;
  height: 4em;
  background: #fff;
  filter: drop-shadow(0px 5px 10px rgba(100, 100, 100, 0.49))
}

nav .nav_links {
  height: 4em;
  display: flex;
  justify-content: space-around;
  align-items: center;
/*   width: 15%; */
  list-style: none;
/*   margin-left: 1em; */
}

nav .nav_links li a{
  margin-left: 1em;
  text-decoration: none;
  font-size: 2rem;
  color: pink;
}

header .logo {
  height: 130px;
  width: 130px;
  cursor: pointer;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -18px;
}

header .center-circle {
  border-radius: 50%;
  width: 80px;
  height: 80px;
  background-color: white;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -1px;
}

header .clock {
  height: 2em;
  text-transform: uppercase;
  font-size: 2rem;
  color: darkblue;
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  right: 1em;
}
代码语言:javascript
复制
// Automatic Clock
setInterval(getTime, 1000);

function getTime() {
  const date = new Date();
  const hours = date.getHours();
  // const seconds = date.getSeconds()
  const minutes = date.getMinutes();
  const ampm = hours >= 12 ? 'pm' : 'am';
  
  document.getElementById("clock").innerHTML = `${hours}:${minutes} ${ampm}`;
  // if you want seconds to show: add ${seconds}
}

https://codepen.io/NathanielD/pen/YzWqdvV

票数 0
EN

Stack Overflow用户

发布于 2020-10-18 00:54:18

如果你想在这里得到html和css格式的答案

我在您的.nav_links类上使用了flex属性,只需在8:34的时候为您创建另一个类名.time,并将其设置为position:absoluteright:5%。让我知道它是否对你有效。

代码语言:javascript
复制
.logo {
  height: 130px;
  width: 130px;
  cursor: pointer;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -18px;
}
.nav_links {
    display: flex;
    list-style: none;
}
.time {
    position: absolute;
    right: 5%;
}
li {
    color: rgb(255, 177, 190);
    font-size: 15px;
} 
.nav_links a{
    text-decoration: none;
    color: rgb(255, 177, 190);
    font-size: 15px;
    padding: 15px;
}
#circle {
  border-radius: 50%;
  width: 80px;
  height: 80px;
  background-color: white;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -1px;
  -webkit-box-shadow: 0px 3px 15px rgba(100, 100, 100, 0.49);
  -moz-box-shadow: 0px 3px 15px rgba(100, 100, 100, 0.49);
  box-shadow: 0px 3px 15px rgba(100, 100, 100, 0.49);
}

#rect {
  width: 120px;
  height: 65px;
  background-color: white;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: -1px;
}
代码语言:javascript
复制
<header>

        <div id="circle"></div>
        <div id="rect"></div>
        <img src="img/MU-logo.png" alt="Madridismo" class="logo">
      
        <nav>
          <ul class="nav_links">
            <li><a href="index.html">Home</a></li>
            <li><a href="index.html">Games</a></li>
            <li class="time">8:34 AM</li>
          </ul>
        </nav>
      
        <div id="clock"></div>
      
      </header>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64400883

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档