我想爲我的第一個網站建立菜單欄。正確顯示1280x800菜單的窗口分辨率。但是,縮小菜單時,菜單開始對齊不正確。如何調整窗口大小時正確對齊菜單項?
HTML:
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'home/style.css' %}"/>
<div class="menu">
<a href="/" class="logo"></a>
<a href="/shop" class="shopbtn" style="text-decoration:none">Buy Cherry</a>
</div>
CSS:
body {
background-color: lightgrey;
}
.menu {
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: white;
min-height: 10%;
min-width: 150%;
}
.logo {
position: fixed;
top: 0%;
left: 0%;
right: 0%;
background-image: url('http://i.imgur.com/kMdEoP6.png');
width: 250px;
height: 55px;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.logo:hover {
background-image: url('http://i.imgur.com/7d2V63b.png');
width: 249px;
height: 55px;
}
.shopbtn {
position: fixed;
font-size: 12pt;
right: 10%;
left: 23%;
top: 5%;
white-space: nowrap;
color: black;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
float: right;
}
.shopbtn:hover {
color: darkred;
我已經嘗試了所有的元素加入margin-left
和margin-right
與汽車的聲明,但菜單會陷入困境,仍然會錯誤地調整大小時去。
什麼是在縮放時保持導航器正確的解決方案?有沒有可以解決問題的佈局?這可以在不使用Javascript的情況下完成嗎?
添加您的完整代碼,因爲在這裏只有購買櫻花鏈接是可見的,看不到您的標誌。創建一個jsfiddle會對你非常有用。 – frnt