0

我已经完成了一个网站,但我遇到了问题。我有一个侧边栏,其中包含指向屏幕左侧其他页面的绿色链接。其余内容在黄色边栏的右侧。我遇到的问题是该网站在我的屏幕上看起来不错,但是,在我以较大或较小的分辨率查看该网站时,文本和其他内容被转移到侧边栏的绿色中。我将身体的宽度设置为 100%。我不确定问题是什么。CSS:

body
{
    background-image:url(Images/testbackground.jpg);
    width:100%


}

#Links
{
    float: left;
    width: 10%;
    margin: 0;
    padding: 0;
    height: 200px;



}



#ContentLayout
{
    clear: right;
    float: right;
    width: 80%;
    font-size:18px;
}



#wrapper
{
    margin: 0 auto;
    width:100%;

}

HTML:

<body>

<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" media="all" href="OldHome.css" />
<![endif]-->

<div id="wrapper">

<img src="Images/logo.jpg" name="Logo" id="Logo"  />


<div id="Links">
  <a href="index.html"><img src="Images/HomeLogo.jpg" alt="home" border="0px" /></a>
  <br />
  <a href="Programs.html"><img src="Images/ProgramsLogo.jpg" alt="programs" border="0px" /></a>
  <br />
  <a href ="Services.html"><img src="Images/ServicesLogo.jpg" alt="services" border="0px" /></a>
  <br />
  <a href ="Contact.html"><img src="Images/ContactLogo.jpg" alt="contact" border="0px" /></a>
  <br />
  <a href ="OtherLinks.html"><img src="Images/OtherLinksLogo.jpg" alt="links" border="0px" /></a>
  <br />
  <a href ="FAQ.html"><img src="Images/FAQLogo.jpg" alt="faq" border="0px" /></a>
  <br />
  <a href="Feedback.html"><img src="Images/FeedBackLogo.JPG" alt="feedback" border="0px" /></a>
  <br />
  <a href="Photos.html"><img src="Images/PhotosLogo.JPG" alt="photos" border="0px" /></a>
</div>

<div id="header"> 
    <h1><center>

  <u>Home</u>

  <p><img src="Images/OutsideBld2.jpg" width="600" height="500" /></p>
    </center></h1>
</div>
    <div id="ContentLayout">
      <h3 style="padding-left:30px"><center>Mission Statement</center></h3>
<p id="MissionStatement">The Employment Preparation Centre offers employment assistance programs and services to clients at no charge. These are available on a one-on-one basis or in group settings.

Programs and services at The Employment Preparation Centre are based on a belief that a person’s employability is enhanced through &nbsp;self-assessment, knowledge of the current labour market, and development of a return-to-work action plan.</p>
<p id="MissionStatement">
Programs and services at The Employment Preparation Centre are funded through the Department of Advanced Education and Skills under several key divisions.
</p>
<br />
<br />

<p>Trouble finding us?</p>
<!-- Google map START -->
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=10+Main+Street,+Corner+Brook&amp;aq=&amp;sll=39.017445,-98.196116&amp;sspn=35.694805,86.044922&amp;ie=UTF8&amp;hq=&amp;hnear=10+Main+St,+Corner+Brook,+Division+No.+5,+Newfoundland+and+Labrador+A2H+1C6,+Canada&amp;t=m&amp;z=14&amp;ll=48.951917,-57.947721&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=10+Main+Street,+Corner+Brook&amp;aq=&amp;sll=39.017445,-98.196116&amp;sspn=35.694805,86.044922&amp;ie=UTF8&amp;hq=&amp;hnear=10+Main+St,+Corner+Brook,+Division+No.+5,+Newfoundland+and+Labrador+A2H+1C6,+Canada&amp;t=m&amp;z=14&amp;ll=48.951917,-57.947721" style="color:#0000FF;text-align:left">View Larger Map</a></small>
<!-- Google map END -->
<p>This page has <span><?=$hits;?></span> hits</p>
<address>

&copy; 2012
</address>
</div>
</div>

<script type="text/javascript">
  var $buoop = {}
      $buoop.ol = window.onload;
      window.onload=function(){
        if ($buoop.ol) $buoop.ol();
        var e = document.createElement("script");
    e.setAttribute("type", "text/javascript");
        e.setAttribute("src", "http://browser-update.org/update.js");
        document.body.appendChild(e);
      }
    </script>




</body>
</html>
4

4 回答 4

0

确保您的区域和文本的位置设置为绝对?

于 2012-07-16T13:25:26.283 回答
0

问题是你的宽度。#Links 始终占屏幕的 10%,内容区域始终占屏幕的 80%。所以如果你把视口变小,总有 10% 和 80% 的分配。字体保持不变,因此它会尝试使文本适合 10% 和 80% 的区域。

也许您应该尝试使用绝对宽度和媒体查询

这是一个小提琴,它仍然是糟糕的 css,但它可以工作(添加了一个修复链接宽度) http://jsfiddle.net/dennym/AGt9L/

于 2012-07-16T13:33:17.750 回答
0

问题是,如果您将所有列宽都以百分比表示,则站点在某些分辨率(视口宽度)下可能看起来很糟糕。我建议您将菜单栏设置为固定大小(例如 200 像素)并提供内容 div width: auto(即没有宽度)。两个 div 都应该保持浮动。使包装器也固定大小。这样,两个容器就在旁边。菜单列的宽度是固定的,而内容列的宽度加起来是父宽度,即包装器的宽度。

我也重组了你的 HTML 代码。

这是一个JsFiddle(图像不工作,CSS 仍然有点糟糕)。

于 2012-07-16T13:34:29.913 回答
0

我认为你的标记顺序可能是罪魁祸首。如果你像在这个 JSFiddle 中那样移动东西,布局的适应性要强得多,而不必 position:absolute;

于 2012-07-16T13:37:26.283 回答