首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何固定HTML网页的宽度

如何固定HTML网页的宽度
EN

Stack Overflow用户
提问于 2018-06-09 06:38:04
回答 1查看 59关注 0票数 0

所以我正在为HTML编写我的最后一个项目,当格式化图片时,我不小心把它放得太右了,它水平地扩展了我的网页,现在我已经修复了图像,在右边有很多额外的空间。同样的事情也发生在垂直方向,但我只是将body标签的高度设置为100%,它会处理它,我尝试过使用width,但它只是缩小了我的内容,而不改变网页的物理大小。如果你们能提供任何帮助我将不胜感激。这是网页enter image description here的图片

以下是代码

<html>
<title> Bodybuilding </title>


<head>
<style>

.image1 {
	z-index: -1;
	
}

.active {
	background-color: #000000
}

.image2 {
	position: absolute;
	right: 26px;
	top: 10px;
}
.title {
	position: relative;
	top: -250px;
	border-style: solid;
	border-color: #0E878A;
	font-size: 49.5px;

}

ul {
	list-style-type: none;
	margin: 0;
	padding: 0;
	overflow: hidden;
	position: relative;
	top: -245px;
	background-color: #333;
	border-top: 2px solid #bbb;
	border-left: 2px solid #bbb;
	border-bottom: 2px solid #bbb;
	border-radius: 10px;
}
li {
	float: left;
	border-right: 2px solid #bbb;
	
	
}

li a {
	display: inline;
	color: #0E878A;
	text-align: center;
	padding: 15px;
	text-decoration: none;
	font-size: 35px;
}
li a:hover {
	background-color: #111;
}

h2 {
	position: relative;
	top: -797px;
}

p {
	position: relative;
	top: -797px;
	font-size: 30px;
}

.arnold {
	position: relative;
	left : 1130px;
	top: -235px;


}

body {
	background: linear-gradient(#939FA0,#41858B);
	height: 100%;
	width: 98.27%;

}

h3 {
	position: relative;
	top: -765px;


</style>
</head>

<div class="image1">
	<img src="bbifbb.png" width="359" height="250">
</div>
<div class="image2">
	<img src="bbphil.jpg" width="359" height="250">
</div>

<div class ="title">
<center>
<h1> Bodybuilding </h1>
</center>
</div>

<body bgcolor="#939FA0">

<body>

<ul>
	<li><a class = "active" href="bbfinal.html">Home</a></li>
	<li><a href="bbfamous.html">Famous Bodybuilders</a></li>
	<li><a href="bbolympia.html">Mr. Olympia</a></li>
	<li><a href="bbsteroids.html">Steroids</a></li>
	<li><a href="bbmodern.html">Modern Bodybuilders</a></li>
	<li><a href="bbcompetitions.html">Competitions</a></li>
	<li><a href="bbimagemap.html">Find Competitions</a></li>
	<li><a href="bbcontact.html">Contact Me</a></li>
	

</ul>

<div class ="arnold">
<img src="bbarnold.jpg">
</div>

EN

回答 1

Stack Overflow用户

发布于 2018-06-09 06:41:40

您在代码中执行以下操作:

.arnold {
    position: relative;
    left : 1130px;
    top: -235px;
}

因为位置是相对的,所以left属性将所有具有类'arnold‘的元素的左边缘设置为其正常位置右侧的1130个像素。这会在右侧产生额外的滚动空间。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50769223

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档