html - 如何使用 css 修复我网站中的 Logo 位置

标签 html css

我想修复圆形标志的位置,我如何才能使它与我在下面分享的设计最终结果完全一样。

最终结果:

Final result

html:

<nav></nav>
<header>
  <div class="logo">

  </div>
</header>
<div class="main">
  <div class="title">
    <h1>Mohammad Mehrabi - محمد محرابی</h1>
    <h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facilis, eius.</h3>
  </div>
</div>

CSS:

nav{
  height: 40px;
  background: #a1504b;
  border-bottom: 2px solid #8c4742;
}
header{
  background: #443a33 url("http://www.transparenttextures.com/patterns/az-subtle.png") repeat;
  height: 150px;
  border-bottom: 2px solid #38302a;
}
.logo{
  height: 150px;
  width: 150px;
  margin: 0 auto;
  background-color: #202727;
  -webkit-border-radius: 100px;
  -moz-border-radius: 100px;
  border-radius: 100px;
  border:1px #28221e solid;
  box-shadow:  0 0 3px #222;
}

.main{
  height: 1000px;
  background: #222 url("http://www.transparenttextures.com/patterns/az-subtle.png") repeat;
}

.title{
  padding: 1em 0;
  text-align: center;
}
.title h1{
  font-family: Arial;
  font-weight: normal;
  font-size: 24px;
  color: #ddd;
  text-shadow: 1px 1px 0 #000;
}
.title h3{
  font-family: Arial;
  font-weight: normal;
  font-size: 14px;
  color: #fbc36a;
  text-shadow: 1px 1px 0 #000;
}

我的代码的实时预览:http://codepen.io/mehrabi/pen/MKRVJg

最佳答案

绝对定位圆圈,使其位于 DOM 的其余部分之上。您可以将以下内容添加到您的 .logo 并且它会起作用(请注意,您可以通过将左/右 CSS 属性归零并将边距设置为 auto):

.logo {
  position: absolute;
  top: 120px;
  left: 0;
  right: 0;
  margin: auto;
}

我更新了您的 codepen 示例,现在可以使用了: http://codepen.io/staypuftman/pen/rxbvVm

关于html - 如何使用 css 修复我网站中的 Logo 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35465527/

相关文章:

html - 如何访问 HTML5 视频解码功能?

html - 为什么在 chrome 中第一次点击没有激活链接?

html - 使两个搜索字段填充 100% 宽度

javascript - Angular 确认框样式

html - 博主:如何完全禁用Lightbox?

javascript - CKEditor:删除 'Link Type' 选项,但将 URL 设置为默认链接类型?

javascript - Datatable获取行数据未定义错误

html - 悬停时图像上 float 文本的 CSS 问题

javascript - 使 HTML 页面的元素在另一个 HTML 页面中可访问

css - 如果都设置为 1em,为什么 div 的文本和按钮的文本大小不同?