我正在嘗試使用Materialize.css框架爲導航欄中的徽標調整大圖。使用CSS將徽標的高度&寬度降低到7%,這樣就可以將圖像放入導航欄中。但是,縮略圖的實際寬度(<a>
標籤)仍爲1280px
。導航欄中的徽標已調整大小,但鏈接的縮略圖保留了原始比例
我該如何縮小縮略圖的寬度以適合相應的圖像?請參閱下面的代碼 - 我也爲這個項目提供了一個Codepen。提前致謝!
HTML:
<html>
<head>
<title>Bill Test Page</title>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<nav>
<div class="nav-wrapper white">
<a href="#" class="brand-logo"><img src="http://www.vectortemplates.com/raster/batman/batman-logo-big.gif" id="logo" /></a>
<ul id="nav-mobile" 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>
</ul>
</div>
</nav>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"> </script>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js"> </script>
</body>
</html>
CSS:
#logo {
height: 7%;
width: 7%;
padding: 7px;
}
.nav-wrapper #nav-mobile li a {
color: black;
}
.nav-wrapper #nav-mobile li a:hover {
background: black;
color: white;
}
因此,圖像被調整大小,你希望'a'標籤獲得與圖像相同的寬度? – gsamaras
@gsamaras是的,我希望'a'標籤與圖像的寬度相同 – mtaggart
@mtaggart我添加了一個新的答案,我認爲它對您會有好處。 –