Comments (3)
BFC实现
<body>
<div class='content'>
<div class="left"></div>
<div class="right"></div>
</div>
</body>
<style>
.content {
overflow: hidden;
width: 100%;
border: 1px solid pink;
}
.left {
float: left;
width: 100px;
height: 100px;
border: 1px solid #000;
}
.right {
height: 100px;
border: 1px solid red;
}
</style>
Flex实现
<body>
<div class='content'>
<div class="left"></div>
<div class="right"></div>
</div>
</body>
<style>
.content {
display: flex;
border: 1px solid pink;
}
.left {
width: 100px;
height: 100px;
border: 1px solid #000;
}
.right {
flex: 1;
height: 100px;
border: 1px solid red;
}
</style>
float 布局
<body>
<div class='content'>
<div class="left"></div>
<div class="right"></div>
</div>
</body>
<style>
.content {
width: 100%;
border: 1px solid pink;
}
.left {
width: 100px;
height: 100px;
float: left;
background: blue;
}
.right {
width: 100%;
background: red;
height: 100px;
}
</style>
calc 布局
<body>
<div class='content'>
<div class="left"></div>
<div class="right"></div>
</div>
</body>
<style>
* {
margin: 0;
padding: 0;
font-size: 0;
}
.content {
width: 100%;
border: 1px solid pink;
}
.left {
width: 100px;
height: 100px;
display: inline-block;
background: blue;
}
.right {
width: calc(100% - 100px);
background: red;
display: inline-block;
height: 100px;
}
</style>
from daily.
position布局
<body>
<div class='outside'>
<div class="left"></div>
<div class="right"></div>
</div>
</body>
<style>
.outside {
width: 100%;
height: 300px;
position: relative;
}
.left {
width: 100px;
height: 100%;
background: blue;
}
.right {
position: absolute;
left: 100px;
right: 0;
top: 0;
bottom: 0;
background: red;
}
</style>
from daily.
也可以使用margin 为负值实现
from daily.
Related Issues (20)
- 第二十三题:新窗口打开链接的方法是什么?那么如何使全站链接都打开新窗口? HOT 1
- 第二十四题:介绍一下HTML5中的ruby标签 HOT 2
- 第二十五题:new操作符都做了什么事情? HOT 2
- 第二十六题:你所在的团队有规范吗?举例说明都定义了哪些规范? HOT 1
- 第二十七题:用洗牌算法实现一个打乱数组的方法 HOT 3
- 第二十八题:实现数组的并、交、差、补集这四个方法 HOT 2
- 第二十九题:什么是链表? HOT 1
- 第三十题:两数相加
- 第三十一题:描述一下原型和原型链,以及之间的关系
- 第三十二题:什么是高阶函数? HOT 1
- 第三十三题:柯里化?
- 第三十四题:如何快速的适应新工作?
- 第三十五题:为什么不常用table和iframe这两个元素?
- 第三十六题:聊聊单元测试?
- 第三十七题:void 0 HOT 1
- 第三十八题:BEM 规范 HOT 1
- 第三十九题:Webpack的优缺点 HOT 1
- 第四十题:实现一个Promise HOT 1
- 第四十一题:TypeScript的优劣点 HOT 1
- 第四十二题:React 获取 ref 的方法都有哪些? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from daily.