云端漂移 2019-07-01

!important > 行内样式 > #id > .class > tag > * > 继承 > 默认

块格式化上下文(Block Formatting Context,BFC)
1. 根元素 1. position: absolute/fixed 2. display: inline-block / table 3. float 元素 4. ovevflow !== visible



<style>
.blue {
background: blue;
margin: 10px 0;
}
.red {
background: red;
margin: 10px 0;
}
</style>
<body>
<div class="blue">blue</div>
<div class="red">red</div>
</body>
<style>
.blue {
background: blue;
margin: 10px 0;
}
.red-box {
overflow: hidden;
}
.red {
background: red;
margin: 10px 0;
}
</style>
<body>
<div class="blue">blue</div>
<div class="red-box">
<div class="red">red</div>
</div>
</body>
https://www.cnblogs.com/ianya...
https://www.jianshu.com/p/fc1...

https://github.com/ljianshu/B...
继承就是指子节点默认使用父节点的样式属性。
1.可继承:颜色,文字,字体间距行高对齐方式,和列表的样式可以继承
所有元素可继承:visibility和cursor。 内联元素可继承:letter-spacing、word-spacing、white-space、line-height、color、font、font-family、font-size、font-style、font-variant、font-weight、text-decoration、text-transform、direction。 终端块状元素可继承:text-indent和text-align。 列表元素可继承:list-style、list-style-type、list-style-position、list-style-image。
https://www.nowcoder.com/ques...
.p1 {
font-size: 1em;
}
.div {
font-size: 30px;
}
.div p {
font-size: 1em;
}
</style>
<body>
<div class="p1">我的父级是body</div>
<div class="div">
<p>我的父级是div</p>
</div>
</body>
psd设计图的宽度是750px,如何做移动端的适配?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
.box {
width: 7.5rem;
height: 1.0rem;
line-height: 1.0rem;
border: 1px solid #ccc;
}
</style>
<script>
document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
</script>
</head>
<body>
<div class="box">
<p>i am p</p>
</div>
<!-- 不能放在这里 -->
<!-- <script>
(function() {
document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
})
</script> -->
</body>
</html>
https://www.jianshu.com/p/a0b...
<style>
.p1 {
width: 100px;
border: 1px solid #ccc;
}
.p1 {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap
}
</style>
<body>
<p class="p1">CSS文本溢出显示省略号CSS文本溢出显示省略号</p>
</body>
<style>
.div {
width: 100px;
border: 1px solid #ccc;
}
.div {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
</style>
<body>
<div class="div">CSS文本溢出显示省略号CSS文本溢出显示省略号CSS文本溢出显示省略号</div>
</body>
<style>
.box {
width: 0;
height: 0;
border-top: 10px solid red;
border-right: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid transparent;
}
</style>
<body>
<div class="box"></div>
</body>
<style>
.shrink {
-webkit-transform: scale(0.8);
-o-transform: scale(1);
display: inline-block;
}
</style>
<div class="shrink">
shrink
</div>
四个过渡属性
<style>
.box {
width: 100px;
height: 100px;
background: red;
transition: width 2s ease 1s;
}
.box:hover {
width: 200px;
}
</style>
<body>
<div class="box"></div>
</body>