【问题标题】:Bootstrap navbar-brand logo/svg positioningBootstrap navbar-品牌标志/svg定位
【发布时间】:2016-02-16 05:49:13
【问题描述】:

这就是我想要的

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

【问题讨论】:

  • 您希望徽标像您的图片一样溢出导航栏?
  • 是的,这是我想出的 codepen.io/anon/pen/avPgMJ 的演示,但我不知道我做得对不对,我希望专业人士能告诉我。

标签: html css twitter-bootstrap svg navbar


【解决方案1】:

这是基于您发布的图片的示例。其中绝大多数只是样式和少量的结构调整,主要是为了抵消 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>

【讨论】:

  • 非常感谢!非常有帮助,非常感谢。
  • 没问题,很高兴能帮上忙!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-08
  • 2017-03-08
  • 1970-01-01
相关资源
最近更新 更多