Javascript 使用截面和侧边自定义布局
我想旁边是右边,部分是左边。一切都应该在空间的中间。 请看看这个 包装纸{ 宽度:100%; 身高:100%; } 标题{ 宽度:100%; 高度:50px; 背景颜色:绿色; } 导航{ 宽度:100%; 高度:50px; 背景色:红色; } 部分{ 宽度:50%; 高度:100px; 背景颜色:黄色; 浮动:左; } 旁白{ 浮动:对; 宽度:50%; 高度:200px; 背景颜色:绿色; } 文章{ 浮动:左; 宽度:50%; 高度:100px; 背景颜色:橙色; } 页脚{ 宽度:100%; 高度:50px; 显示:内联块; 背景颜色:蓝色; } 标题 航行 部分 部分 文章 页脚Javascript 使用截面和侧边自定义布局,javascript,html,css,twitter-bootstrap,visual-studio-2013,Javascript,Html,Css,Twitter Bootstrap,Visual Studio 2013,我想旁边是右边,部分是左边。一切都应该在空间的中间。 请看看这个 包装纸{ 宽度:100%; 身高:100%; } 标题{ 宽度:100%; 高度:50px; 背景颜色:绿色; } 导航{ 宽度:100%; 高度:50px; 背景色:红色; } 部分{ 宽度:50%; 高度:100px; 背景颜色:黄色; 浮动:左; } 旁白{ 浮动:对; 宽度:50%; 高度:200px; 背景颜色:绿色; } 文章{ 浮动:左; 宽度:50%; 高度:100px; 背景颜色:橙色; } 页脚{ 宽度:10
试试这个代码。你要试试这个吗 有没有可能使该部分更接近?我想一切都有宽度800内的内容。作为布局的内容位于中间,但左侧仍然有一个部分,右侧仍然有一个部分。宽度不是100%,而是800像素。如果您需要更多信息,请告诉我将样式100%更改为800px。并设置“margin:auto;”
<!DOCTYPE html>
<html>
<head>
<style>
#main {
width: 800px;
margin: 0 auto;
}
.righttt{
position: relative;
right: 0px;
width: 200px;
}
section {
overflow: left;
}
</style>
</head>
<body>
<header>
<h1>City Gallery</h1>
</header>
<div id="main">
<section>
<h1>London</h1>
<p>
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
</p>
<p>
Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.
</p>
</section>
<section>
<h1>London</h1>
<p>
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
</p>
<p>
Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.
</p>
</section>
<aside class="righttt">
<h1>London</h1>
<p>
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
</p>
<p>
Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.
</p>
</aside>
</div>
<footer>
Copyright © W3Schools.com
</footer>
</body>
</html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
<script type="text/javascript" src="/js/lib/dummy.js"></script>
<link rel="stylesheet" type="text/css" href="/css/result-light.css">
<style type="text/css">
#main {
width: 100%;
margin: 0 auto;
text-align: center;
}
section {
overflow: left;
float: left;
width: 75%;
}
.righttt {
position: relative;
right: 0px;
width: 25%;
float: right;
}
</style>
</head>
<body>
<header>
<h1>City Gallery</h1>
</header>
<div id="main">
<section>
<h1>London</h1>
<p>
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
</p>
<p>
Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.
</p>
</section><aside class="righttt">
<h1>London</h1>
<p>
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
</p>
<p>
Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.
</p>
</aside>
<section>
<h1>London</h1>
<p>
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
</p>
<p>
Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.
</p>
</section>
</div>
<div style="width: 100%;float: left; text-align: center;"><footer>
Copyright © W3Schools.com
</footer></div>
</body></html>