这个问题只是关于我在屏幕顶部的菜单,但它也适用于我在页面上的Ny表。
每当我调整浏览器大小时,都没有任何动作。它们都停留在同一个地方,只是被切断了屏幕。
HTML:
<div class="navigation">
<a href="../Page2/Page2.HTML"><object class="menu" id="Rosa"> Rosa Parks </object></a>
<a href="../Page3/Page3.HTML"><object class="menu" id="Martin">Martin Luther Jr.</object></a>
<a href="../page4/Page4.html"><object class="menu" id="Malcom">Maclom X</object></a>
<a href="../Page5/Page5.html"><object class="menu" id="Design">Design</object></a>
<a href="../Page1/Website.html"><object class="menu" id="BlackTitle">Black History Site</object></a>
<a href="../Page1/Website.html"> <img id="Fist" src="../Assets/Fist.png" alt="White Fist"/></a>
</div>
CSS:
* {
margin: 0;
padding: 0;
}
body {
background-color: grey;
}
.navigation {
width: 1280px;
height: 60px;
background-color: black;
position: absolute;
}
.menu {
display: inline-block;
color: white;
float: right;
}
#Rosa {
color: White;
font-family: Arial Black;
width: 100px;
height: 25px;
min-height: 5px;
padding: 2px;
border-bottom: 1px solid white;
border-top: 1px solid white;
overflow: hidden;
margin: 14px 1165px;
position: absolute;
}
#Martin {
color: White;
font-family: Arial Black;
width: 147px;
height: 25px;
padding: 2px;
border-bottom: 1px solid white;
border-top: 1px solid white;
overflow: hidden;
margin: 14px 995px;
position: absolute;
}
#Malcom {
color: white;
font-family: Arial Black;
width: 87px;
height: 25px;
padding: 2px;
border-bottom: 1px solid white;
border-top: 1px solid white;
overflow: hidden;
margin: 14px 885px;
position: absolute;
}
#Design {
color: white;
font-family: Arial Black;
width: 60px;
height: 25px;
padding: 2px;
border-bottom: 1px solid white;
border-top: 1px solid white;
overflow: hidden;
margin: 14px 800px;
position: absolute;
}
#BlackTitle {
color: white;
font-family: "Bree Serif", "serif";
width: 380px;
height: 50px;
float: right;
font-size: 40px;
padding: 10px;
overflow: hidden;
margin: -8px 250px;
letter-spacing: 2px;
position: absolute;
}
.navigation a {
text-decoration: none;
color: black;
}
#Fist {
max-height: 3.77em;
float: left;
margin-right: 5px;
position:absolute;
}
如果您还有其他需要,请告诉我。这个问题让我抓狂,因为我无法弄清楚我做错了什么。
答案 0 :(得分:2)
这里有一些问题......
以下是CodePen:https://codepen.io/anon/pen/aWpRBq
不确定为什么你有<object>
元素,但我删除了它们。我也简化了你的CSS。如果将浏览器缩小到导航进入标题的位置,布局仍将中断,但您需要使用媒体查询进行修复。
* {
margin: 0;
padding: 0;
}
body {
background-color: grey;
}
.navigation {
width: 100%;
height: 60px;
background-color: black;
position: absolute;
}
.navigation ul{
float: right;
position: relative;
top: 20px;
}
.navigation li{
display: inline;
padding: 0 10px;
}
.navigation ul li a{
color: White;
font-family: Arial Black;
height: 25px;
padding: 2px;
border-bottom: 1px solid white;
border-top: 1px solid white;
text-decoration: none;
}
.blackTitle {
color: white;
display: block;
float: left;
font-family: "Bree Serif", "serif";
font-size: 40px;
padding:10px;
letter-spacing: 2px;
text-decoration: none;
}
<nav class="navigation">
<a href="../Page1/Website.html" class="blackTitle">Black History Site</a>
<ul>
<li>
<a href="../Page5/Page5.html">Design</a>
</li>
<li>
<a href="../page4/Page4.html">Maclom X</a>
</li>
<li>
<a href="../Page3/Page3.HTML">Martin Luther Jr.</a>
</li>
<li>
<a href="../Page2/Page2.HTML">Rosa Parks</a>
</li>
</ul>
</nav>
答案 1 :(得分:0)
如果可以尝试响应式设计。这将根据屏幕尺寸调整内容。
您只需浏览以下链接即可了解响应式设计
http://www.entheosweb.com/website_design/responsive_web_design.asp
http://learn.shayhowe.com/advanced-html-css/responsive-web-design/
如果您想暂时解决问题,只需将所有宽度设为百分比即可。