我在我的网页上的div上使用了百分比,但我遇到的问题是div扩展太远并且创建了一个不受欢迎的水平滚动条,我希望div扩展到页面的100%而不超过它。任何帮助将非常感谢我已经查看了图像大小并与它们混在一起,现在已经尝试了100%宽度,但无济于事。
因此,为了澄清我想要水平页面宽度以适应页面宽度,但不是为了创建水平滚动条。
下面是我的HTML和CSS:
HTML:
<html>
<head>
<meta content="en-gb" http-equiv="Content-Language">
<title>dfgfdgdfg</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
#picturecontainer2 {
border-style: none;
float: left;
}
</style>
</head>
<body>
<div id="bannerdiv" align="left" title="Banner">
<img alt="z" height="114" src="Untitled3.jpg" width="100%"></div>
<div id="container">
<h3 class="auto-style4" id="container">drgrgergergdg</h3>
</div>
<div id="menubar" style="width: 16%; height: 100px;" title="menu" align = "center">
<ul>
<li style ="align = center;""><img alt="logo" height="63" src="images/drgrg.gif" width="126"></li>
<li ><a href="index.html" style="height: 20px; class="auto-style5">Home</a></li>
<li><a href="general.html">General</a></li>
<li><a href="map.html">Site map</a></li>
<li><a href="rules.html">Rules & Procdures</a></li>
<li><a href="enviro.html" style="height: 20px">Envirommental</a></li>
<li><a href="energy.html">Energy</a></li>
<li><a href="it.html">IT</a></li>
<li><a href="sap.html">SAP</a></li>
<li><a href="purchasing.html" style="height: 20px; width: 180px;">Purchasing</a></li>
<li><a href="quality.html">Quality</a></li>
<li><a href="safety.html">Safety</a></li>
<li><a href="hr.html">Human resources</a></li>
<li><a href="prod.html">Production</a></li>
<li><a href="eng.html">Engineering</a></li>
<li><a href="feedback.html">Feedback</a></li>
<li><a href="tees.html">Teesdock</a></li>
<li><a href="cmp.html">Company mobile phones</a></li>
<li><a href="cms.html">Climate Survery Updates</a></li>
<li><a href="training.html">Training</a></li>
<li><a href="sports.html">Sports Dome</a></li>
</ul>
</div>
<div id="mainpage" class="auto-style1" style="height: 96px; width: 84%; float:right;height:80; color: #000000; font-size: 11pt; left: 0px; top: 176px;">
<font face="Garamond"><font face="Arial" size="4">
<p><b>SPORTS DOME</b></p>
<p><span lang="en-gb"><b><font color="#ff0000" face="Arial" size="4">
Contact Craig Bayliss Ext 3600 for all Dome bookings, events, circuit
training, weight training, table tennis etc.</font></b></span></p>
<p><span lang="en-gb"><font color="#000000" face="Arial"><b>
Click</b></font><font face="Arial"> on the links below for more information</font></span></p>
<p>
</font><font face="Arial">
<a href="file://cplfs01/dept/sports%20dome/Application%20Forms" style="TEXT-DECORATION: none">
Application Forms</a></font></p>
<p><font face="Arial">
<a href="file://cplfs01/dept/sports%20dome/Rules%20and%20Procedures" style="TEXT-DECORATION: none">
Rules and Procedures</a> </font></p>
<p><font face="Arial">
<a href="file://cplfs01/dept/sports%20dome/Sports%20Dome%20Booking%20Forms" style="TEXT-DECORATION: none">
Sports Dome Booking Forms</a></font></p>
</font>
</div>
<h3 class="auto-style4" id="container1"style = width:100%></h3>
</div>
<br>
<div id="picturecontainer2" style ="float: left;">
<img alt="z" height="114" src="da.png" width="100%"></div>
</div>
</body>
</html>
CSS:
#container {
margin: 0px;
background-color: #008852;
font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif;
color: #FFFFFF;
text-align: left;
max-width: 10%;
}
#main
{
height:100%;
weight:100&
}
html, body {
overflow: auto;
height: 100%;
}
#picturecontainer1{
float: left;
}
#mainpage {
border: thin solid #008852;
width: 84%;
float: left;
background-color: #EDEFEE;
height: auto;
border-radius: 20px;
height: 100%;
position: fixed;
color: #008852;
}
#menubar
ul
{
list-style-type: none;
margin: 0;
padding: 0;
float: left;
}
#menubar a:link, #menubar a:visited
{
border-top-width: 1px;
display: block;
font-weight: bold;
color: #000000;
background-color: #EFF1EB;
width: 180px;
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
border-style: solid;
border-color: #638529;
font-family: Arial, Helvetica, sans-serif;
border: 1px;
position: fixed;
}
#menubar a:hover, #menubar a:active
{
background-color: #7A991A;
}
#menubar {
border-width: 1px;
border-style: none;
font-size: xx-small;
width: 50%;
margin-top: 11px;
float: left;
vertical-align: 0%;
}
#bannerdiv
{
margin-bottom:20px;
}
.newStyle1 {
text-align: left;
}
footer {
font-family: Arial, Helvetica, sans-serif;
text-align: left;
background-color: #008852;
}
.auto-style1 {
text-align: center;
margin-left: 0px;
margin-top: 11px;
font-family: Georgia;
margin-right: 0px;
}
s
#bannerdiv {
text-align: center;
}
.auto-style4 {
margin-left: 0px;
text-align: left;
}
.auto-style5 {
margin-top: 0px;
}
.auto-style8 {
text-align: left;
font-size: xx-small;
}
.auto-style6 {
text-align: left;
font-size: xx-small;
font-weight: bold;
}
.auto-style10 {
margin-left: 0px;
}
.auto-style12 {
text-align: left;
font-size: xx-small;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
}
.auto-style11 {
font-family: Arial, Helvetica, sans-serif;
}
.auto-style9 {
font-family: "Franklin Gothic Medium";
position: fixed;
}
#container1 {
font-family: Arial, Helvetica, sans-serif;
margin-top: 20px;
background-color: #008852;
clear: right;
}
#table {
}
#mainpage a:link, #mainpage a:visited {
font-family: Arial, Helvetica, sans-serif;
font-size: small;
font-weight: bold;
}
#picturecontainer2 {
border-style: none;
float: left;
}
#picturecontainer1 {
border-style: none;
width: 126px;
border-right-width: thick;
border-bottom-width: thick;
border-left-width: thick;
}
.auto-style20 {
text-align: center;
}
.auto-style21 {
border-collapse: collapse;
border-width: 0px;
background-color: #EDEFEE;
}
.auto-style19 {
text-align: left;
font-size: small;
font-family: Arial, Helvetica, sans-serif;
}
.auto-style17 {
text-align: left;
font-size: x-small;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
}
.auto-style15 {
text-align: left;
font-size: x-small;
font-weight: normal;
}
.auto-style18 {
text-align: left;
font-size: 12pt;
}
#mainpage a:link, #mainpage a:visited {
}
.auto-style23 {
font-family: Arial, Helvetica, sans-serif;
font-size: 11pt;
a text-decoration: none;
}
.auto-style14 {
font-family: Arial, Helvetica, sans-serif;
font-size: 9pt;
}
.auto-style15 {
text-align: left;
font-size: 9pt;
font-weight: normal;
}
.auto-style17 {
text-align: left;
font-size: 9pt;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
}
.auto-style18 {
text-align: left;
font-size: 12pt;
}
.auto-style19 {
text-align: left;
font-size: small;
font-family: Arial, Helvetica, sans-serif;
}
#picturecontainer2 {
border-style: none;
float: left;
}
.auto-style20 {
text-align: left;
font-size: 9pt;
font-family: Arial, Helvetica, sans-serif;
}
.auto-style21 {
font-weight: normal;
}
#picturecontainer2 {
border-style: none;
float: left;
}
.auto-style14 {
text-align: center;
}
.auto-style15 {
font-family: Arial, Helvetica, sans-serif;
text-align: center;
}
#mainpage a:hover a: active {
font-family: Arial, Helvetica, sans-serif;
}
.auto-style25 {
text-align: left;
font-weight: normal;
font-family: Arial, Helvetica, sans-serif;
}
.auto-style26 {
text-align: left;
font-size: x-small;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
}
.auto-style27 {
text-align: left;
font-size: small;
font-family: Arial, Helvetica, sans-serif;
}
答案 0 :(得分:3)
您可以使用CSS Overflow;
overflow-x:hidden;
这将隐藏水平滚动条
答案 1 :(得分:2)
是的,添加溢出:隐藏在你的CSS中 并且请不要使用内联css和外部CSS,它使我们的观众更难以阅读和理解。始终使用任何一个 - 首选外部css
答案 2 :(得分:1)
添加:
overflow:hidden;
到你想要的divs CSS
答案 3 :(得分:1)
overflow-x:hidden; 你可以修复那个错误。