請教一下,一個奇怪的佈局問題

xk2y 2015-03-11 07:41:47
問題是這樣的。
主体是960px宽,720px高,居中对齐(margin:0 auto),然后在主体两旁各有一个可以自适应显示的图片(屏幕有多宽,两边就显示多少),两侧的图片会紧贴主体。

那么怎样写css?或者是用js控制?
...全文
135 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
天际的海浪 2015-03-11
  • 打赏
  • 举报
回复

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.box {
	position: relative;
}
.main {
	position: absolute;
	left: -480px;
	margin-left: 50%;
	width: 960px;
	height: 720px;
	background-color: #ff0;
}
.l {
	position: absolute;
	left: 0px;
	right: 480px;
	margin-right: 50%;
	width: auto;
	height: 500px;
	background-color: #f00;
}
.r {
	position: absolute;
	right: 0px;
	left: 480px;
	margin-left: 50%;
	width: auto;
	height: 500px;
	background-color: #f00;
}
</style>
</head>
<body>
<div class="box">
	<div class="l"></div>
	<div class="main"></div>
	<div class="r"></div>
</div>
</body>
</html>

39,084

社区成员

发帖
与我相关
我的任务
社区描述
HTML5是构建Web内容的一种语言描述方式。HTML5是互联网的下一代标准,是构建以及呈现互联网内容的一种语言方式.被认为是互联网的核心技术之一。
社区管理员
  • HTML5社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧