byr-gdp / 40layoutexercise Goto Github PK
View Code? Open in Web Editor NEW40个布局练习
40个布局练习
Line 21 in 263a28e
若不给wrapper设置float而设置inline-block,则navigation和extra不会回到上一行。感觉这个地方是float的一个特性,但是并不明白是什么特性。
首先非常感谢您写的这个样式库,让我能有各种布局的练习,我不知道是我的方式有问题(我将您的模版进行了修改,但保留了对应的结构),按照您的样式书写是有问题的,我的推测是应为您的content中的内容较长,宽度足以撑开,否则在float为浮动的情况下,margin:0 200px并不能实现居中的效果。我觉得稳妥的情况应该是将wrapper的宽度用calc(100% - 400px)计算出来,这样的情况下无论内容多少,都可以达到居中的效果。
不知道我上面的理解是否正确,如果有什么不对的,望您指出,谢谢!
下面我放上我的代码
<!DOCTYPE html>
<html lang="zh-CN">
<meta charset="utf-8">
<title>三栏布局-浮动实现</title>
<link ref="stylesheet" href="normalize.css">
<style>
.article {
/* width: 700px; */
/* margin: 0 200 0 200; */
}
.wrapper {
/* width: 400px; */
width: calc(100% - 400px);
float: left;
margin: 0 200px;
background-color: yellow;
}
.nav {
width: 200px;
float: left;
margin-left: -200px;
background-color: red;
}
.aside {
width: 200px;
float: left;
margin-left: -100%;
background-color: blue;
}
.footer {
clear: both;
}
</style>
<body>
<article class="article">
<header class="header">Header</header>
<div class="wrapper">
<section>Content</section>
</div>
<nav class="nav">Navigation</nav>
<aside class="aside">Extra stuff</aside>
<footer class="footer">Footer</footer>
</article>
</body>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.