html - Bootstrap navbar-brand logo/svg定位

标签 html css twitter-bootstrap svg navbar

这是我想要的

http://i.imgur.com/3WFNg1f.png

这是我想出的:

HTML

  <a class="navbar-brand" href="#">
  <div class="eye">

  <svg width="50" height="50" version="1.1" x="0px" y="0px" viewBox="0 0 380 296" xml:space="preserve">
  <g>
  <g>
  <defs>
  <rect x="0.922" y="1" width="378.156" height="302" />
  </defs>
  <path fill-rule="evenodd" clip-rule="evenodd" d="M189.967,1C121.452,1,52.925,50.029,0.915,148.048
  c52.01,98.071,120.537,147.047,189.052,147.047c68.58,0,137.108-48.977,189.117-147.047C327.075,50.029,258.547,1,189.967,1
  L189.967,1z M189.967,253.091c-49.804,0-100.369-37.947-140.785-105.043C89.598,81.017,140.163,43.004,189.967,43.004
  c49.856,0,100.435,38.013,140.85,105.044C290.402,215.145,239.823,253.091,189.967,253.091L189.967,253.091z M190.952,90.496
  c-33.935,0-61.505,27.57-61.505,61.505c0,34.03,27.57,61.504,61.505,61.504c34.03,0,61.6-27.474,61.6-61.504
  C252.552,118.066,224.982,90.496,190.952,90.496L190.952,90.496z M189.967,106.043" />
  </g>
  </g>
  </svg>

  </div>
  </a>

CSS

.eye {
position: absolute;
background-color: black;
width: 65px;
height: 65px;
top: 0;
left: 17px;
}

.eye svg {
margin: 8px 8px 8px 8px;
fill: white;
}

.navbar-brand {
float: left;
height: 50px;
padding: 15px 50px;
font-size: 18px;
line-height: 20px;
}

还有其他方法吗?因为我觉得我的方法不对。

演示: http://codepen.io/anon/pen/avPgMJ

最佳答案

这是一个基于您发布的图片的示例。其中绝大多数只是样式和最少量的结构调整,主要是为了抵消 SVG 下的内容,因此根本没有重叠。

查看工作代码段。

.navbar.navbar-default {
  background-color: white;
  border: 3px solid #222;
  margin-bottom: 60px;
  margin-top: 15px;
}
.navbar-nav.navbar-right {
  margin-right: 0px;
}
.eye {
  background-color: #222;
  width: 100px;
  height: 100px;
  margin-top: -15px;
  z-index: 1051.
}
.eye svg {
  margin: 25px;
  fill: #7D0000;
}
@media (max-width: 767px) {
  .navbar.navbar-default .navbar-collapse {
    border: none;
    box-shadow: none;
  }
  .navbar.navbar-default .navbar-left {
    margin-top: 50px;
  }
  .navbar.navbar-default .navbar-toggle,
  .navbar.navbar-default .navbar-toggle:hover,
  .navbar.navbar-default .navbar-toggle:focus {
    border: none;
    background: none;
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
  <nav class="navbar navbar-default navbar-static-top">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-nv" aria-expanded="false"> <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>

      </button>
      <a class="navbar-brand" href="#">
        <div class="eye">

          <svg width="50" height="50" version="1.1" x="0px" y="0px" viewBox="0 0 380 296" xml:space="preserve">
            <g>
              <g>
                <defs>
                  <rect x="0.922" y="1" width="378.156" height="302" />
                </defs>
                <path fill-rule="evenodd" clip-rule="evenodd" d="M189.967,1C121.452,1,52.925,50.029,0.915,148.048
			c52.01,98.071,120.537,147.047,189.052,147.047c68.58,0,137.108-48.977,189.117-147.047C327.075,50.029,258.547,1,189.967,1
			L189.967,1z M189.967,253.091c-49.804,0-100.369-37.947-140.785-105.043C89.598,81.017,140.163,43.004,189.967,43.004
			c49.856,0,100.435,38.013,140.85,105.044C290.402,215.145,239.823,253.091,189.967,253.091L189.967,253.091z M190.952,90.496
			c-33.935,0-61.505,27.57-61.505,61.505c0,34.03,27.57,61.504,61.505,61.504c34.03,0,61.6-27.474,61.6-61.504
			C252.552,118.066,224.982,90.496,190.952,90.496L190.952,90.496z M189.967,106.043" />
              </g>
            </g>
          </svg>

        </div>
      </a>

    </div>
    <div class="collapse navbar-collapse" id="bs-nv">
      <ul class="nav navbar-nav navbar-left">
        <li><a href="#">Link</a>

        </li>
        <li><a href="#">Link</a>

        </li>
        <li><a href="#">Link</a>

        </li>
        <li><a href="#">Link</a>

        </li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Link</a>

        </li>
      </ul>
    </div>
  </nav>
</div>
<div class="container">
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
    publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer
    took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
    sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>

关于html - Bootstrap navbar-brand logo/svg定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33713205/

相关文章:

html - 表格中的 SVG - Chrome、Firefox、IE

html - 响应图像 : Srcset & sizes

c# - 在 ASP.NET MVC 中解码标签

jquery - 关于 Div 的问题;悬停,事件,内容

html - 如何创建水平元素列表?

html - 如何覆盖CSS分组样式

angularjs - Bootstrap 模态的简单 Angular 指令

html - HTML 页面中的奇怪行为

css - 合并两个相邻 sibling 的CSS

css - 使用显示 : table 时需要删除 Safari 中显示的额外像素