我正在物化框架中创建一个网站.导航栏中的徽标有问题.所以我的徽标非常大(6202×3800像素),我没有任何其他版本.我想将此徽标放在导航栏中,但它总是超出导航包装器的框架.我尝试添加class responsive-img,但它根本不起作用.
这是我的代码:
#allcontent { background-color: white; margin: 2%; } body { background: #d26335; } nav { color: black; }
<div class="row" id="allcontent"> <div class="navbar-default" id="navbar"> <nav class="white"> <div class="nav-wrapper"> <a href="index.html" class="brand-logo left"><img class="responsive-img" id="logo" src="<!-- my image -->"/></a> <ul id="nav-mobile" class="right hide-on-med-and-down"> <li><a href="sass.html"><i class="material-icons">search</i></a> </li> <li>colors</li> </ul> </div> </nav> </div> </div>
解决方法
您所要做的就是使用CSS控制图像的大小到您想要的任何尺寸:
.navbar-material .nav-wrapper .brand-logo img { height: 64px; }
或者使用图像编辑器将图像大小调整为更合理的标识,以便开始使用徽标.参见Photoshop,GIMP或Sketch,仅举几例.
(*并且肯定会@R_502_216@;如果你没有使用构建系统来执行此操作,那么总是像TINYpng那样)
请参阅工作示例代码段.
(**注意使用的所有类都是默认的MaterialCSS减去.navbar-material类,看起来你将Bootstrap3类与MaterialCSS类混合)
$(".button-collapse").sideNav();
body { background: #d26335; } nav.navbar-material { background: #d26335; border: none; Box-shadow: none; } .navbar-material .nav-wrapper { background: white; margin: 20px; } .navbar-material .nav-wrapper > ul > li > a { color: black; } .navbar-material .nav-wrapper .brand-logo img { height: 64px; } .navbar-material .nav-wrapper .button-collapse i { color: black; } @media (max-width: 600px) { .navbar-material .nav-wrapper .brand-logo img { height: 56px; } }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/js/materialize.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/css/materialize.min.css" rel="stylesheet" /> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <nav class="navbar-material"> <div class="nav-wrapper"> <a href="#!" class="brand-logo"> <img src="http://placehold.it/6202x3800/FF001E/fff"> </a> <a href="#" data-activates="mobile-demo" class="button-collapse"><i class="material-icons">menu</i></a> <ul class="right hide-on-med-and-down"> <li><a href="sass.html">Sass</a> </li> <li><a href="badges.html">Components</a> </li> <li><a href="collapsible.html">Javascript</a> </li> <li><a href="mobile.html">Mobile</a> </li> </ul> <ul class="side-nav" id="mobile-demo"> <li><a href="sass.html">Sass</a> </li> <li><a href="badges.html">Components</a> </li> <li><a href="collapsible.html">Javascript</a> </li> <li><a href="mobile.html">Mobile</a> </li> </ul> </div> </nav>