这就是我想要的
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;
}
还有另一种方法吗?因为我觉得我的方式是错的。
答案 0 :(得分: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;
}
}
&#13;
<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>
&#13;