node

node

Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境。
javascript/jQuery

javascript/jQuery

一种直译式脚本语言,是一种动态类型、弱类型、基于原型的语言,内置支持类型。
MongoDB

MongoDB

MongoDB 是一个基于分布式文件存储的数据库
openstack

openstack

OpenStack是一个由NASA(美国国家航空航天局)和Rackspace合作研发并发起的,以Apache许可证授权的自由软件和开放源代码项目。
VUE

VUE

一套构建用户界面的渐进式框架。与其他重量级框架不同的是,Vue 采用自底向上增量开发的设计。
bootstrap

bootstrap

Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile first projects on the web.
HTML

HTML

超文本标记语言,标准通用标记语言下的一个应用。
CSS/SASS/SCSS/Less

CSS/SASS/SCSS/Less

层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
PHP

PHP

PHP(外文名:PHP: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言。语法吸收了C语言、Java和Perl的特点,利于学习,使用广泛,主要适用于Web开发领域。PHP 独特的语法混合了C、Java、Perl以及PHP自创的语法。它可以比CGI或者Perl更快速地执行动态网页。用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML(标准通用标记语言下的一个应用)文档中去执行,执行效率比完全生成HTML标记的CGI要高许多;PHP还可以执
每天进步一点点

每天进步一点点

乌法把门的各累笑寂静
求职招聘

求职招聘

猎头招聘专用栏目
Python

Python

一种解释型、面向对象、动态数据类型的高级程序设计语言。

使用css3 grid 重构media 组件

lopo1983 发表了文章 • 0 个评论 • 1800 次浏览 • 2018-03-08 00:21 • 来自相关话题

请着重看less部分代码
html<template lang="pug">
section(:class="`${type}`")
.object
slot(name="object")
.content
slot(name="body")
.footer
slot(name="footer")
</template>js<script>
export default {
name: "gridMedia",
props: {
type: {
type: String,
default: "media"
}
}
};
</script>less<style lang="less" scoped>
@import (reference) "../../assets/lib/css.less";
.media {
display: grid;
grid-template-rows: repeat(2, auto);
grid-template-columns: 25% calc(~"75% - 1.25rem");
grid-auto-rows: auto;
grid-template-areas: "object content" "object footer";
grid-gap: 0 1.25rem;
.pd(1.25rem);
.object {
grid-area: object;
}
.content {
grid-area: content;
}
.footer {
grid-area: footer;
align-self: flex-end;
}
&.right {
grid-template-columns: calc(~"75% - 1.25rem") 25%;
grid-template-areas: "content object" "footer object";
}
&.thumbnail {
grid-template-rows: repeat(3, auto);
grid-template-columns: auto;
grid-template-areas: "object" "content" "footer";
grid-gap: 1.25rem;
}
}
</style>最终效果截图





? 查看全部

请着重看less部分代码


html
<template lang="pug">
section(:class="`${type}`")
.object
slot(name="object")
.content
slot(name="body")
.footer
slot(name="footer")
</template>
js
<script>
export default {
name: "gridMedia",
props: {
type: {
type: String,
default: "media"
}
}
};
</script>
less
<style lang="less" scoped>
@import (reference) "../../assets/lib/css.less";
.media {
display: grid;
grid-template-rows: repeat(2, auto);
grid-template-columns: 25% calc(~"75% - 1.25rem");
grid-auto-rows: auto;
grid-template-areas: "object content" "object footer";
grid-gap: 0 1.25rem;
.pd(1.25rem);
.object {
grid-area: object;
}
.content {
grid-area: content;
}
.footer {
grid-area: footer;
align-self: flex-end;
}
&.right {
grid-template-columns: calc(~"75% - 1.25rem") 25%;
grid-template-areas: "content object" "footer object";
}
&.thumbnail {
grid-template-rows: repeat(3, auto);
grid-template-columns: auto;
grid-template-areas: "object" "content" "footer";
grid-gap: 1.25rem;
}
}
</style>
最终效果截图

QQ图片20180308001833.png

?

关于 bootstrap <media object>变迁

lopo1983 发表了文章 • 0 个评论 • 1751 次浏览 • 2018-02-05 10:16 • 来自相关话题

media 组件是一个很常用的bootstrap组件 官方的用途解释为:
?
这是一个抽象的样式,用以构建不同类型的组件,这些组件都具有在文本内容的左或右侧对齐的图片(就像博客评论或 Twitter 消息等高度重复的组件
?3.x 的html结构如下:
3.x布局方式 使用的是 display table-cell
<div class="media">
<div class="media-left media-middle">
<a href="#">
<img class="media-object" src="..." alt="...">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">Middle aligned media</h4>
...
</div>
</div><ul class="media-list">
<li class="media">
<div class="media-left">
<a href="#">
<img class="media-object" src="..." alt="...">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">Media heading</h4>
...
</div>
</li>
</ul>3.x 传送门??点我
?
4.x 的结构有些变化 变得更灵活 也更高端(IE10+)
4.x使用 display flex 布局
<div class="media">
<img class="align-self-center mr-3" src="..." alt="Generic placeholder image">
<div class="media-body">
<h5 class="mt-0">Center-aligned media</h5>
<p>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.</p>
<p class="mb-0">Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div>
</div><ul class="list-unstyled">
<li class="media">
<img class="mr-3" src="..." alt="Generic placeholder image">
<div class="media-body">
<h5 class="mt-0 mb-1">List-based media object</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</li>
<li class="media my-4">
<img class="mr-3" src="..." alt="Generic placeholder image">
<div class="media-body">
<h5 class="mt-0 mb-1">List-based media object</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</li>
<li class="media">
<img class="mr-3" src="..." alt="Generic placeholder image">
<div class="media-body">
<h5 class="mt-0 mb-1">List-based media object</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</li>
</ul>4.x 传送门 点我
?
关于object 左右的问题 3.x 和4.x 都可以通过对 object流位置进行调整来进行,但4.x还可以通过 设置对应order来直接替换? 关于bootstrap4.x的flex 设置 点我
?使用 display grid 来实现一个media object(grid 传送门 点我)
?
css
.media {
display: grid;
grid-template-rows: repeat(2, auto);
grid-template-columns: 25% calc(~"75% - 1.25rem");
grid-auto-rows: auto;
grid-template-areas: "object content" "object footer";
grid-gap: 0 1.25rem;
.object {
grid-row: 1 / span 2;
grid-column: 1;
}
.content {
grid-row: 1;
grid-column: 2;
}
.footer {
grid-row: 2;
grid-column: 2;
align-self: flex-end;
display: flex;
flex-direction: row;
justify-content: space-between;
}
} 查看全部
media 组件是一个很常用的bootstrap组件 官方的用途解释为:
?

这是一个抽象的样式,用以构建不同类型的组件,这些组件都具有在文本内容的左或右侧对齐的图片(就像博客评论或 Twitter 消息等高度重复的组件


?3.x 的html结构如下:
3.x布局方式 使用的是 display table-cell
<div class="media">
<div class="media-left media-middle">
<a href="#">
<img class="media-object" src="..." alt="...">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">Middle aligned media</h4>
...
</div>
</div>
<ul class="media-list">
<li class="media">
<div class="media-left">
<a href="#">
<img class="media-object" src="..." alt="...">
</a>
</div>
<div class="media-body">
<h4 class="media-heading">Media heading</h4>
...
</div>
</li>
</ul>
3.x 传送门??点我
?
4.x 的结构有些变化 变得更灵活 也更高端(IE10+)
4.x使用 display flex 布局
<div class="media">
<img class="align-self-center mr-3" src="..." alt="Generic placeholder image">
<div class="media-body">
<h5 class="mt-0">Center-aligned media</h5>
<p>Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.</p>
<p class="mb-0">Donec sed odio dui. Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div>
</div>
<ul class="list-unstyled">
<li class="media">
<img class="mr-3" src="..." alt="Generic placeholder image">
<div class="media-body">
<h5 class="mt-0 mb-1">List-based media object</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</li>
<li class="media my-4">
<img class="mr-3" src="..." alt="Generic placeholder image">
<div class="media-body">
<h5 class="mt-0 mb-1">List-based media object</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</li>
<li class="media">
<img class="mr-3" src="..." alt="Generic placeholder image">
<div class="media-body">
<h5 class="mt-0 mb-1">List-based media object</h5>
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. Donec lacinia congue felis in faucibus.
</div>
</li>
</ul>
4.x 传送门 点我
?

关于object 左右的问题 3.x 和4.x 都可以通过对 object流位置进行调整来进行,但4.x还可以通过 设置对应order来直接替换? 关于bootstrap4.x的flex 设置 点我


?使用 display grid 来实现一个media object(grid 传送门 点我
?
css
.media {
display: grid;
grid-template-rows: repeat(2, auto);
grid-template-columns: 25% calc(~"75% - 1.25rem");
grid-auto-rows: auto;
grid-template-areas: "object content" "object footer";
grid-gap: 0 1.25rem;
.object {
grid-row: 1 / span 2;
grid-column: 1;
}
.content {
grid-row: 1;
grid-column: 2;
}
.footer {
grid-row: 2;
grid-column: 2;
align-self: flex-end;
display: flex;
flex-direction: row;
justify-content: space-between;
}
}

本站的VUE 实例中所用到的less 库

lopo1983 发表了文章 • 0 个评论 • 1902 次浏览 • 2017-06-26 12:59 • 来自相关话题

很多vue 文件里面会出来一个less 基础库 请下载放到assets>lib(可按照你习惯的路径安放 修改路径即可)
下载地址如下?
很多vue 文件里面会出来一个less 基础库 请下载放到assets>lib(可按照你习惯的路径安放 修改路径即可)
下载地址如下?

less 基础css类(v1.1)

lopo1983 发表了文章 • 0 个评论 • 2030 次浏览 • 2017-06-23 13:27 • 来自相关话题

/*httpimg*/
@bgimg: "https://qmarket.bj.bcebos.com/PB150703.jpg";
/*颜色变量*/
@ces: @cbl; //颜色网站基础色
@cun: transparent; //透明背景
@cwh: rgb(255, 255, 255); //白色
/*flat 推荐颜色*/
/*http://bsfans.com/fc/index.html*/
@cor: rgb(230, 126, 34); //橙色
@cor1: rgb(211, 84, 0);
@cbl: rgb(52, 152, 219); //蓝色
@cbl1: rgb(41, 128, 185);
@cgr: rgb(46, 204, 113); //绿色
@cgr1: rgb(39, 174, 96);
@cye: rgb(241, 196, 15); //黄色
@cye1: rgb(243, 156, 18);
@cre: rgb(231, 76, 60); //红色
@cre1: rgb(192, 57, 43);
@cgy: rgb(236, 240, 241); //灰色
@cgy1: rgb(189, 195, 199);
@cbla: rgb(0,0,0); //黑色
//
/*文字颜色*/
@cc: rgb(68,68,68); //文字主要颜色
@cc1: rgb(46,46,46); //文字主要颜色
@cc2: rgb(153,153,153); //文字主要颜色
@cc3: rgb(51,51,51); //文字主要颜色
@cc4: rgb(246,246,246); //黑色背景颜色
/*背景色*/
@bgc: rgb(34, 34, 34);
@bgcc: rgb(21, 33, 47);
@bgc1: rgb(241, 241, 241);
@bgc2: rgb(238,238,238);
@bgc3: rgb(70,69,83);
@bgc4: rgb(54, 62, 75);
//
@cbsw: rgb(252, 248, 227);
//
/*边框颜色*/
@bdrc: rgb(225, 225, 225); //边框颜色
/*自定义颜色占位*/
@nbgc:rgb(47,64,80);
@nbg:rgb(41,56,70);
@idc: rgba(255,255,255,.5);
/* */
/*其他常用变量*/
/*文字*/
@ffmix: "Helvetica Neue",Helvetica,Arial,"Microsoft Yahei","Hiragino Sans GB","Heiti SC","WenQuanYi Micro Hei",sans-serif;
//
@rem: 14px; //
@hack: ~"\9"; //
@mpb: 15px; //基础单位
//常用class配置
.bgcw{
background-color: @cwh;
}
.bgcb{
background-color: @cbla;
}
.bgce{
background-color: @ces;
}
.bgc(@c){
background-color: @c;
}
//....
.db{
display: block;
}
.dn{
display: none;
}
.dib{
display: inline-block;
}
.di{
display: inline;
}
//....
.pr{
position: relative;
}
.ps{
position: absolute;
}
.pf{
position: fixed;
}
//边框控制
.bdr(@w:1px, @s:solid, @cr:@bdrc) {
border: @w @s @cr;
}
.bdrt(@w:1px, @s:solid, @cr:@bdrc) {
border-top: @w @s @cr;
}
.bdrr(@w:1px, @s:solid, @cr:@bdrc) {
border-right: @w @s @cr;
}
.bdrb(@w:1px, @s:solid, @cr:@bdrc) {
border-bottom: @w @s @cr;
}
.bdrl(@w:1px, @s:solid, @cr:@bdrc) {
border-left: @w @s @cr;
}
//内外边距控制
.mg(@a:@mpb) {
margin: @a;
}
.mgt(@a:@mpb) {
margin-top: @a;
}
.mgr(@a:@mpb) {
margin-right: @a;
}
.mgb(@a:@mpb) {
margin-bottom: @a;
}
.mgl(@a:@mpb) {
margin-left: @a;
}
.pd(@a:@mpb) {
padding: @a;
}
.pdt(@a:@mpb) {
padding-top: @a;
}
.pdr(@a:@mpb) {
padding-right: @a;
}
.pdb(@a:@mpb) {
padding-bottom: @a;
}
.pdl(@a:@mpb) {
padding-left: @a;
}
//clear
.clear {
&:after,
&:before {
content: "";
display: table;
}
&:after {
clear: both;
}
}
.cp{
cursor: pointer;
}
//居中
.amid {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
}
.flmm {
display: flex;
display: -webkit-flex;
justify-content: center;
align-items: center;
}
/**
* animation
*/
.key (@prefix, @name, @content) when (@prefix=def) {
@keyframes @name {
@content();
}
}
.key (@prefix, @name, @content) when (@prefix=moz) {
@-moz-keyframes @name {
@content();
}
}
.key (@prefix, @name, @content) when (@prefix=o) {
@-o-keyframes @name {
@content();
}
}
.key (@prefix, @name, @content) when (@prefix=webkit) {
@-webkit-keyframes @name {
@content();
}
}
.key (@prefix, @name, @content) when (@prefix=all) {
.key(moz,@name,@content);
.key(o,@name,@content);
.key(webkit,@name,@content);
.key(def,@name,@content);
}
//trandorm
.trf(@content) {
-webkit-transform: @content;
-moz-transform: @content;
-ms-transform: @content;
-o-transform: @content;
transform: @content;
}
//animation
.ani(@n:ani, @t:1s, @t2:.5s, @fn:ease-in-out, @i:infinite, @dur:alternate) {
animation: @n @t @t2 @fn @i @dur;
-webkit-animation: @n @t @t2 @fn @i @dur;
-o-animation: @n @t @t2 @fn @i @dur;
-moz-animation: @n @t @t2 @fn @i @dur;
}
//过度
.trs(@t:.5s, @b: ease-in-out) {
transition: all @t @b;
-webkit-transition: all @t @b;
-ms-transition: all @t @b;
}
//去除设置
.unbg {
background: transparent;
}
.unbdr {
border-radius: 0;
}
.unbd {
border: none;
}
.unbs {
box-shadow: none;
-webkit-box-shadow: none;
-ms-box-shadow: none;
}
.unst {
padding-left: 0;
list-style: none;
}
.list-inline {
.unst;
> li {
display: inline-block;
padding-right: 5px;
padding-left: 5px;
}
}
.unl {
text-decoration: none;
}
//杂项
.round {
border-radius: 50%;
}
.ohd {
overflow: hidden;
}
.ohy{
overflow-y: auto;
}
.ohx{
overflow-x: auto;
}
//文字方向控制
.tac {
text-align: center;
}
.tal {
text-align: left;
}
.tar {
text-align: right;
}
.taj {
text-align: justify;
}
//
.textoh {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.blod {
font-weight: bolder;
}
//flex center
.fc {
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
.mask {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
//iconfont 建议使用强大的iconfont
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
position: relative;
display: inline-block;
top: 1px;
}
//loop

.col-loop(@n, @i:@cgy1) when (@i=<@n) {
.col-xs-@{i} {
.pdl(0);
.pdr(0);
}
.col-loop(@n,(@i+1));
}

//extend
.abs {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.ffull{
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
line-height: 100vh;
}
.scroll {
&::-webkit-scrollbar-track {
width: 3px;
background-color: @cgy;
}
&::-webkit-scrollbar {
width: 3px;
height: @mpb;
background-color: @ces;
}
&::-webkit-scrollbar-thumb {
background-color: @ces;
}
} 查看全部
/*httpimg*/
@bgimg: "https://qmarket.bj.bcebos.com/PB150703.jpg";
/*颜色变量*/
@ces: @cbl; //颜色网站基础色
@cun: transparent; //透明背景
@cwh: rgb(255, 255, 255); //白色
/*flat 推荐颜色*/
/*http://bsfans.com/fc/index.html*/
@cor: rgb(230, 126, 34); //橙色
@cor1: rgb(211, 84, 0);
@cbl: rgb(52, 152, 219); //蓝色
@cbl1: rgb(41, 128, 185);
@cgr: rgb(46, 204, 113); //绿色
@cgr1: rgb(39, 174, 96);
@cye: rgb(241, 196, 15); //黄色
@cye1: rgb(243, 156, 18);
@cre: rgb(231, 76, 60); //红色
@cre1: rgb(192, 57, 43);
@cgy: rgb(236, 240, 241); //灰色
@cgy1: rgb(189, 195, 199);
@cbla: rgb(0,0,0); //黑色
//
/*文字颜色*/
@cc: rgb(68,68,68); //文字主要颜色
@cc1: rgb(46,46,46); //文字主要颜色
@cc2: rgb(153,153,153); //文字主要颜色
@cc3: rgb(51,51,51); //文字主要颜色
@cc4: rgb(246,246,246); //黑色背景颜色
/*背景色*/
@bgc: rgb(34, 34, 34);
@bgcc: rgb(21, 33, 47);
@bgc1: rgb(241, 241, 241);
@bgc2: rgb(238,238,238);
@bgc3: rgb(70,69,83);
@bgc4: rgb(54, 62, 75);
//
@cbsw: rgb(252, 248, 227);
//
/*边框颜色*/
@bdrc: rgb(225, 225, 225); //边框颜色
/*自定义颜色占位*/
@nbgc:rgb(47,64,80);
@nbg:rgb(41,56,70);
@idc: rgba(255,255,255,.5);
/* */
/*其他常用变量*/
/*文字*/
@ffmix: "Helvetica Neue",Helvetica,Arial,"Microsoft Yahei","Hiragino Sans GB","Heiti SC","WenQuanYi Micro Hei",sans-serif;
//
@rem: 14px; //
@hack: ~"\9"; //
@mpb: 15px; //基础单位
//常用class配置
.bgcw{
background-color: @cwh;
}
.bgcb{
background-color: @cbla;
}
.bgce{
background-color: @ces;
}
.bgc(@c){
background-color: @c;
}
//....
.db{
display: block;
}
.dn{
display: none;
}
.dib{
display: inline-block;
}
.di{
display: inline;
}
//....
.pr{
position: relative;
}
.ps{
position: absolute;
}
.pf{
position: fixed;
}
//边框控制
.bdr(@w:1px, @s:solid, @cr:@bdrc) {
border: @w @s @cr;
}
.bdrt(@w:1px, @s:solid, @cr:@bdrc) {
border-top: @w @s @cr;
}
.bdrr(@w:1px, @s:solid, @cr:@bdrc) {
border-right: @w @s @cr;
}
.bdrb(@w:1px, @s:solid, @cr:@bdrc) {
border-bottom: @w @s @cr;
}
.bdrl(@w:1px, @s:solid, @cr:@bdrc) {
border-left: @w @s @cr;
}
//内外边距控制
.mg(@a:@mpb) {
margin: @a;
}
.mgt(@a:@mpb) {
margin-top: @a;
}
.mgr(@a:@mpb) {
margin-right: @a;
}
.mgb(@a:@mpb) {
margin-bottom: @a;
}
.mgl(@a:@mpb) {
margin-left: @a;
}
.pd(@a:@mpb) {
padding: @a;
}
.pdt(@a:@mpb) {
padding-top: @a;
}
.pdr(@a:@mpb) {
padding-right: @a;
}
.pdb(@a:@mpb) {
padding-bottom: @a;
}
.pdl(@a:@mpb) {
padding-left: @a;
}
//clear
.clear {
&:after,
&:before {
content: "";
display: table;
}
&:after {
clear: both;
}
}
.cp{
cursor: pointer;
}
//居中
.amid {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
}
.flmm {
display: flex;
display: -webkit-flex;
justify-content: center;
align-items: center;
}
/**
* animation
*/
.key (@prefix, @name, @content) when (@prefix=def) {
@keyframes @name {
@content();
}
}
.key (@prefix, @name, @content) when (@prefix=moz) {
@-moz-keyframes @name {
@content();
}
}
.key (@prefix, @name, @content) when (@prefix=o) {
@-o-keyframes @name {
@content();
}
}
.key (@prefix, @name, @content) when (@prefix=webkit) {
@-webkit-keyframes @name {
@content();
}
}
.key (@prefix, @name, @content) when (@prefix=all) {
.key(moz,@name,@content);
.key(o,@name,@content);
.key(webkit,@name,@content);
.key(def,@name,@content);
}
//trandorm
.trf(@content) {
-webkit-transform: @content;
-moz-transform: @content;
-ms-transform: @content;
-o-transform: @content;
transform: @content;
}
//animation
.ani(@n:ani, @t:1s, @t2:.5s, @fn:ease-in-out, @i:infinite, @dur:alternate) {
animation: @n @t @t2 @fn @i @dur;
-webkit-animation: @n @t @t2 @fn @i @dur;
-o-animation: @n @t @t2 @fn @i @dur;
-moz-animation: @n @t @t2 @fn @i @dur;
}
//过度
.trs(@t:.5s, @b: ease-in-out) {
transition: all @t @b;
-webkit-transition: all @t @b;
-ms-transition: all @t @b;
}
//去除设置
.unbg {
background: transparent;
}
.unbdr {
border-radius: 0;
}
.unbd {
border: none;
}
.unbs {
box-shadow: none;
-webkit-box-shadow: none;
-ms-box-shadow: none;
}
.unst {
padding-left: 0;
list-style: none;
}
.list-inline {
.unst;
> li {
display: inline-block;
padding-right: 5px;
padding-left: 5px;
}
}
.unl {
text-decoration: none;
}
//杂项
.round {
border-radius: 50%;
}
.ohd {
overflow: hidden;
}
.ohy{
overflow-y: auto;
}
.ohx{
overflow-x: auto;
}
//文字方向控制
.tac {
text-align: center;
}
.tal {
text-align: left;
}
.tar {
text-align: right;
}
.taj {
text-align: justify;
}
//
.textoh {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.blod {
font-weight: bolder;
}
//flex center
.fc {
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
.mask {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
//iconfont 建议使用强大的iconfont
.iconfont {
font-family: "iconfont" !important;
font-size: 16px;
font-style: normal;
-webkit-font-smoothing: antialiased;
position: relative;
display: inline-block;
top: 1px;
}
//loop

.col-loop(@n, @i:@cgy1) when (@i=<@n) {
.col-xs-@{i} {
.pdl(0);
.pdr(0);
}
.col-loop(@n,(@i+1));
}

//extend
.abs {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.ffull{
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
line-height: 100vh;
}
.scroll {
&::-webkit-scrollbar-track {
width: 3px;
background-color: @cgy;
}
&::-webkit-scrollbar {
width: 3px;
height: @mpb;
background-color: @ces;
}
&::-webkit-scrollbar-thumb {
background-color: @ces;
}
}

纯css写出小三角和气泡对话框

boloog 发表了文章 • 0 个评论 • 3167 次浏览 • 2017-04-19 18:04 • 来自相关话题

各种小三角实现:在线查看<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.common-div{
width: 0;
height: 0;
margin: 20px;
}
.div1{
border-top: 25px solid blue;
border-left: 25px solid red;
border-right: 25px solid yellow;
border-bottom: 25px solid green;
}
.div2{
border-top: 25px solid blue;
border-left: 25px solid transparent;
border-right: 25px solid transparent;
border-bottom: 25px solid transparent;
}
.div3{
border-top: 25px solid transparent;
border-left: 25px solid red;
border-right: 25px solid transparent;
border-bottom: 25px solid transparent;
}
.div4{
border-top: 25px solid transparent;
border-left: 25px solid transparent;
border-right: 25px solid yellow;
border-bottom: 25px solid transparent;
}
.div5{
border-top: 25px solid transparent;
border-left: 25px solid transparent;
border-right: 25px solid transparent;
border-bottom: 25px solid green;
}
.div6{
border-top: 25px solid transparent;
border-left: 25px solid red;
border-right: 25px solid transparent;
border-bottom: 25px solid red;
}
.div7{
border-top: 25px solid transparent;
border-left: 25px solid transparent;
border-right: 25px solid green;
border-bottom: 25px solid green;
}
</style>
</head>
<body>
<div class="common-div div1"></div>
<div class="common-div div2"></div>
<div class="common-div div3"></div>
<div class="common-div div4"></div>
<div class="common-div div5"></div>
<div class="common-div div6"></div>
<div class="common-div div7"></div>
</body>
</html>
?
?气泡对话框:在线查看<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>css3对话框</title>
<style>
.dialog-box {
width: 200px;
height: 100px;
border: 1px solid #ccc;
position: relative;
margin-top: 30px;
background-color: #fff;
}
.dialog-box-1 .triangle {
width: 0;
height: 0;
border-top: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #ccc;
border-left: 10px solid transparent;
position: absolute;
top: -20px;
left: 10px;
}
.dialog-box-2 .triangle {
width: 0;
height: 0;
border-top: 10px solid red;
border-right: 10px solid red;
border-bottom: 10px solid transparent;
border-left: 10px solid transparent;
position: absolute;
top: -1px;
right: -1px;
}
.dialog-box-3 .triangle {
width: 0;
height: 0;
border-top: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #ccc;
border-left: 10px solid transparent;
position: absolute;
top: -20px;
left: 10px;
}
.dialog-box-3 .triangle:after {
content: "";
border-top: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid #fff;
border-left: 8px solid transparent;
position: absolute;
top: -6px;
left: -8px;
}
</style>
</head>
<body>
<div class="dialog-box dialog-box-1">
<span class="triangle"></span>
</div>
<div class="dialog-box dialog-box-2">
<span class="triangle"></span>
</div>
<div class="dialog-box dialog-box-3">
<span class="triangle"></span>
</div>
</body>
</html> 查看全部
各种小三角实现:在线查看
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.common-div{
width: 0;
height: 0;
margin: 20px;
}
.div1{
border-top: 25px solid blue;
border-left: 25px solid red;
border-right: 25px solid yellow;
border-bottom: 25px solid green;
}
.div2{
border-top: 25px solid blue;
border-left: 25px solid transparent;
border-right: 25px solid transparent;
border-bottom: 25px solid transparent;
}
.div3{
border-top: 25px solid transparent;
border-left: 25px solid red;
border-right: 25px solid transparent;
border-bottom: 25px solid transparent;
}
.div4{
border-top: 25px solid transparent;
border-left: 25px solid transparent;
border-right: 25px solid yellow;
border-bottom: 25px solid transparent;
}
.div5{
border-top: 25px solid transparent;
border-left: 25px solid transparent;
border-right: 25px solid transparent;
border-bottom: 25px solid green;
}
.div6{
border-top: 25px solid transparent;
border-left: 25px solid red;
border-right: 25px solid transparent;
border-bottom: 25px solid red;
}
.div7{
border-top: 25px solid transparent;
border-left: 25px solid transparent;
border-right: 25px solid green;
border-bottom: 25px solid green;
}
</style>
</head>
<body>
<div class="common-div div1"></div>
<div class="common-div div2"></div>
<div class="common-div div3"></div>
<div class="common-div div4"></div>
<div class="common-div div5"></div>
<div class="common-div div6"></div>
<div class="common-div div7"></div>
</body>
</html>

?
?气泡对话框:在线查看
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>css3对话框</title>
<style>
.dialog-box {
width: 200px;
height: 100px;
border: 1px solid #ccc;
position: relative;
margin-top: 30px;
background-color: #fff;
}
.dialog-box-1 .triangle {
width: 0;
height: 0;
border-top: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #ccc;
border-left: 10px solid transparent;
position: absolute;
top: -20px;
left: 10px;
}
.dialog-box-2 .triangle {
width: 0;
height: 0;
border-top: 10px solid red;
border-right: 10px solid red;
border-bottom: 10px solid transparent;
border-left: 10px solid transparent;
position: absolute;
top: -1px;
right: -1px;
}
.dialog-box-3 .triangle {
width: 0;
height: 0;
border-top: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #ccc;
border-left: 10px solid transparent;
position: absolute;
top: -20px;
left: 10px;
}
.dialog-box-3 .triangle:after {
content: "";
border-top: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid #fff;
border-left: 8px solid transparent;
position: absolute;
top: -6px;
left: -8px;
}
</style>
</head>
<body>
<div class="dialog-box dialog-box-1">
<span class="triangle"></span>
</div>
<div class="dialog-box dialog-box-2">
<span class="triangle"></span>
</div>
<div class="dialog-box dialog-box-3">
<span class="triangle"></span>
</div>
</body>
</html>

css居中的几种实现方式

boloog 发表了文章 • 0 个评论 • 1597 次浏览 • 2017-04-18 18:33 • 来自相关话题

1.?使用padding<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.wrap {
width: 300px;
background-color: pink;
padding: 100px 0;
text-align: center;
}
</style>
</head>
<body>
<div class="wrap">
使用padding让文本垂直居中显示
</div>
</body>
</html>2.?使用绝对定位<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.wrap {
width: 300px;
height: 300px;
line-height: 300px;
text-align: center;
background-color: red;
color: #fff;
position: absolute;
top: 50%;
left: 50%;
margin-left: -150px;
margin-top: -150px;
}
</style>
</head>
<body>
<div class="wrap">
使用绝对定位让.wrap垂直居中显示
</div>
</body>
</html>3.?使用CSS3 transform<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.wrap {
width: 300px;
height: 300px;
line-height: 300px;
text-align: center;
background-color: red;
color: #fff;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
</style>
</head>
<body>
<div class="wrap">
使用CSS3 transform让 .wrap垂直居中显示
</div>
</body>
</html>4.?使用伪元素<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.wrap {
width: 400px;
height: 300px;
margin: 0 auto;
background-color: #ccc;
text-align: center;
}
.wrap::before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
}
</style>
</head>
<body>
<div class="wrap">
使用伪元素实现垂直居中
</div>
</body>
</html> 查看全部
1.?使用padding
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.wrap {
width: 300px;
background-color: pink;
padding: 100px 0;
text-align: center;
}
</style>
</head>
<body>
<div class="wrap">
使用padding让文本垂直居中显示
</div>
</body>
</html>
2.?使用绝对定位
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.wrap {
width: 300px;
height: 300px;
line-height: 300px;
text-align: center;
background-color: red;
color: #fff;
position: absolute;
top: 50%;
left: 50%;
margin-left: -150px;
margin-top: -150px;
}
</style>
</head>
<body>
<div class="wrap">
使用绝对定位让.wrap垂直居中显示
</div>
</body>
</html>
3.?使用CSS3 transform
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.wrap {
width: 300px;
height: 300px;
line-height: 300px;
text-align: center;
background-color: red;
color: #fff;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
</style>
</head>
<body>
<div class="wrap">
使用CSS3 transform让 .wrap垂直居中显示
</div>
</body>
</html>
4.?使用伪元素
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.wrap {
width: 400px;
height: 300px;
margin: 0 auto;
background-color: #ccc;
text-align: center;
}
.wrap::before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
}
</style>
</head>
<body>
<div class="wrap">
使用伪元素实现垂直居中
</div>
</body>
</html>

CSS浏览器兼容

回复

boloog 发起了问题 • 0 人关注 • 0 个回复 • 2769 次浏览 • 2017-04-17 19:10 • 来自相关话题

Flex 布局教程:语法篇

lopo1983 发表了文章 • 0 个评论 • 1687 次浏览 • 2016-09-02 12:19 • 来自相关话题

网页布局(layout)是CSS的一个重点应用。

布局的传统解决方案,基于盒状模型,依赖?display属性 +?position属性 +?float属性。它对于那些特殊布局非常不方便,比如,垂直居中就不容易实现。

2009年,W3C提出了一种新的方案----Flex布局,可以简便、完整、响应式地实现各种页面布局。目前,它已经得到了所有浏览器的支持,这意味着,现在就能很安全地使用这项功能。

Flex布局将成为未来布局的首选方案。本文介绍它的语法,下一篇文章给出常见布局的Flex写法。

以下内容主要参考了下面两篇文章:A Complete Guide to Flexbox?和?A Visual Guide to CSS3 Flexbox Properties。

一、Flex布局是什么?

Flex是Flexible Box的缩写,意为"弹性布局",用来为盒状模型提供最大的灵活性。

任何一个容器都可以指定为Flex布局。

.box{ display: flex; }

行内元素也可以使用Flex布局。

.box{ display: inline-flex; }

Webkit内核的浏览器,必须加上-webkit前缀。

.box{ display: -webkit-flex; /* Safari */ display: flex; }

注意,设为Flex布局以后,子元素的float、clear和vertical-align属性将失效。

二、基本概念

采用Flex布局的元素,称为Flex容器(flex container),简称"容器"。它的所有子元素自动成为容器成员,称为Flex项目(flex item),简称"项目"。

容器默认存在两根轴:水平的主轴(main axis)和垂直的交叉轴(cross axis)。主轴的开始位置(与边框的交叉点)叫做main start,结束位置叫做main end;交叉轴的开始位置叫做cross start,结束位置叫做cross end。

项目默认沿主轴排列。单个项目占据的主轴空间叫做main size,占据的交叉轴空间叫做cross size。

三、容器的属性

以下6个属性设置在容器上。

flex-direction
flex-wrap
flex-flow
justify-content
align-items
align-content

3.1 flex-direction属性

flex-direction属性决定主轴的方向(即项目的排列方向)。

.box { flex-direction: row | row-reverse | column | column-reverse; }

它可能有4个值。

row(默认值):主轴为水平方向,起点在左端。
row-reverse:主轴为水平方向,起点在右端。
column:主轴为垂直方向,起点在上沿。
column-reverse:主轴为垂直方向,起点在下沿。

3.2 flex-wrap属性

默认情况下,项目都排在一条线(又称"轴线")上。flex-wrap属性定义,如果一条轴线排不下,如何换行。

.box{ flex-wrap: nowrap | wrap | wrap-reverse; }

它可能取三个值。

(1)nowrap(默认):不换行。

(2)wrap:换行,第一行在上方。

(3)wrap-reverse:换行,第一行在下方。

3.3 flex-flow

flex-flow属性是flex-direction属性和flex-wrap属性的简写形式,默认值为row nowrap。

.box { flex-flow: <flex-direction> || <flex-wrap>; }

3.4 justify-content属性

justify-content属性定义了项目在主轴上的对齐方式。

.box { justify-content: flex-start | flex-end | center | space-between | space-around; }

它可能取5个值,具体对齐方式与轴的方向有关。下面假设主轴为从左到右。

flex-start(默认值):左对齐
flex-end:右对齐
center: 居中
space-between:两端对齐,项目之间的间隔都相等。
space-around:每个项目两侧的间隔相等。所以,项目之间的间隔比项目与边框的间隔大一倍。

3.5 align-items属性

align-items属性定义项目在交叉轴上如何对齐。

.box { align-items: flex-start | flex-end | center | baseline | stretch; }

它可能取5个值。具体的对齐方式与交叉轴的方向有关,下面假设交叉轴从上到下。

flex-start:交叉轴的起点对齐。
flex-end:交叉轴的终点对齐。
center:交叉轴的中点对齐。
baseline: 项目的第一行文字的基线对齐。
stretch(默认值):如果项目未设置高度或设为auto,将占满整个容器的高度。

3.6 align-content属性

align-content属性定义了多根轴线的对齐方式。如果项目只有一根轴线,该属性不起作用。

.box { align-content: flex-start | flex-end | center | space-between | space-around | stretch; }

该属性可能取6个值。

flex-start:与交叉轴的起点对齐。
flex-end:与交叉轴的终点对齐。
center:与交叉轴的中点对齐。
space-between:与交叉轴两端对齐,轴线之间的间隔平均分布。
space-around:每根轴线两侧的间隔都相等。所以,轴线之间的间隔比轴线与边框的间隔大一倍。
stretch(默认值):轴线占满整个交叉轴。

四、项目的属性

以下6个属性设置在项目上。

order
flex-grow
flex-shrink
flex-basis
flex
align-self

4.1 order属性

order属性定义项目的排列顺序。数值越小,排列越靠前,默认为0。

.item { order: <integer>; }

4.2 flex-grow属性

flex-grow属性定义项目的放大比例,默认为0,即如果存在剩余空间,也不放大。

.item { flex-grow: <number>; /* default 0 */ }

如果所有项目的flex-grow属性都为1,则它们将等分剩余空间(如果有的话)。如果一个项目的flex-grow属性为2,其他项目都为1,则前者占据的剩余空间将比其他项多一倍。

4.3 flex-shrink属性

flex-shrink属性定义了项目的缩小比例,默认为1,即如果空间不足,该项目将缩小。

.item { flex-shrink: <number>; /* default 1 */ }

如果所有项目的flex-shrink属性都为1,当空间不足时,都将等比例缩小。如果一个项目的flex-shrink属性为0,其他项目都为1,则空间不足时,前者不缩小。

负值对该属性无效。

4.4 flex-basis属性

flex-basis属性定义了在分配多余空间之前,项目占据的主轴空间(main size)。浏览器根据这个属性,计算主轴是否有多余空间。它的默认值为auto,即项目的本来大小。

.item { flex-basis: <length> | auto; /* default auto */ }

它可以设为跟width或height属性一样的值(比如350px),则项目将占据固定空间。

4.5 flex属性

flex属性是flex-grow,?flex-shrink?和?flex-basis的简写,默认值为0 1 auto。后两个属性可选。

.item { flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ] }

该属性有两个快捷值:auto?(1 1 auto) 和 none (0 0 auto)。

建议优先使用这个属性,而不是单独写三个分离的属性,因为浏览器会推算相关值。

4.6 align-self属性

align-self属性允许单个项目有与其他项目不一样的对齐方式,可覆盖align-items属性。默认值为auto,表示继承父元素的align-items属性,如果没有父元素,则等同于stretch。

.item { align-self: auto | flex-start | flex-end | center | baseline | stretch; }

该属性可能取6个值,除了auto,其他都与align-items属性完全一致。 查看全部
网页布局(layout)是CSS的一个重点应用。

布局的传统解决方案,基于盒状模型,依赖?display属性 +?position属性 +?float属性。它对于那些特殊布局非常不方便,比如,垂直居中就不容易实现。

2009年,W3C提出了一种新的方案----Flex布局,可以简便、完整、响应式地实现各种页面布局。目前,它已经得到了所有浏览器的支持,这意味着,现在就能很安全地使用这项功能。

Flex布局将成为未来布局的首选方案。本文介绍它的语法,下一篇文章给出常见布局的Flex写法。

以下内容主要参考了下面两篇文章:A Complete Guide to Flexbox?和?A Visual Guide to CSS3 Flexbox Properties。

一、Flex布局是什么?

Flex是Flexible Box的缩写,意为"弹性布局",用来为盒状模型提供最大的灵活性。

任何一个容器都可以指定为Flex布局。

.box{ display: flex; }

行内元素也可以使用Flex布局。

.box{ display: inline-flex; }

Webkit内核的浏览器,必须加上-webkit前缀。

.box{ display: -webkit-flex; /* Safari */ display: flex; }

注意,设为Flex布局以后,子元素的float、clear和vertical-align属性将失效。

二、基本概念

采用Flex布局的元素,称为Flex容器(flex container),简称"容器"。它的所有子元素自动成为容器成员,称为Flex项目(flex item),简称"项目"。

容器默认存在两根轴:水平的主轴(main axis)和垂直的交叉轴(cross axis)。主轴的开始位置(与边框的交叉点)叫做main start,结束位置叫做main end;交叉轴的开始位置叫做cross start,结束位置叫做cross end。

项目默认沿主轴排列。单个项目占据的主轴空间叫做main size,占据的交叉轴空间叫做cross size。

三、容器的属性

以下6个属性设置在容器上。

flex-direction
flex-wrap
flex-flow
justify-content
align-items
align-content

3.1 flex-direction属性

flex-direction属性决定主轴的方向(即项目的排列方向)。

.box { flex-direction: row | row-reverse | column | column-reverse; }

它可能有4个值。

row(默认值):主轴为水平方向,起点在左端。
row-reverse:主轴为水平方向,起点在右端。
column:主轴为垂直方向,起点在上沿。
column-reverse:主轴为垂直方向,起点在下沿。

3.2 flex-wrap属性

默认情况下,项目都排在一条线(又称"轴线")上。flex-wrap属性定义,如果一条轴线排不下,如何换行。

.box{ flex-wrap: nowrap | wrap | wrap-reverse; }

它可能取三个值。

(1)nowrap(默认):不换行。

(2)wrap:换行,第一行在上方。

(3)wrap-reverse:换行,第一行在下方。

3.3 flex-flow

flex-flow属性是flex-direction属性和flex-wrap属性的简写形式,默认值为row nowrap。

.box { flex-flow: <flex-direction> || <flex-wrap>; }

3.4 justify-content属性

justify-content属性定义了项目在主轴上的对齐方式。

.box { justify-content: flex-start | flex-end | center | space-between | space-around; }

它可能取5个值,具体对齐方式与轴的方向有关。下面假设主轴为从左到右。

flex-start(默认值):左对齐
flex-end:右对齐
center: 居中
space-between:两端对齐,项目之间的间隔都相等。
space-around:每个项目两侧的间隔相等。所以,项目之间的间隔比项目与边框的间隔大一倍。

3.5 align-items属性

align-items属性定义项目在交叉轴上如何对齐。

.box { align-items: flex-start | flex-end | center | baseline | stretch; }

它可能取5个值。具体的对齐方式与交叉轴的方向有关,下面假设交叉轴从上到下。

flex-start:交叉轴的起点对齐。
flex-end:交叉轴的终点对齐。
center:交叉轴的中点对齐。
baseline: 项目的第一行文字的基线对齐。
stretch(默认值):如果项目未设置高度或设为auto,将占满整个容器的高度。

3.6 align-content属性

align-content属性定义了多根轴线的对齐方式。如果项目只有一根轴线,该属性不起作用。

.box { align-content: flex-start | flex-end | center | space-between | space-around | stretch; }

该属性可能取6个值。

flex-start:与交叉轴的起点对齐。
flex-end:与交叉轴的终点对齐。
center:与交叉轴的中点对齐。
space-between:与交叉轴两端对齐,轴线之间的间隔平均分布。
space-around:每根轴线两侧的间隔都相等。所以,轴线之间的间隔比轴线与边框的间隔大一倍。
stretch(默认值):轴线占满整个交叉轴。

四、项目的属性

以下6个属性设置在项目上。

order
flex-grow
flex-shrink
flex-basis
flex
align-self

4.1 order属性

order属性定义项目的排列顺序。数值越小,排列越靠前,默认为0。

.item { order: <integer>; }

4.2 flex-grow属性

flex-grow属性定义项目的放大比例,默认为0,即如果存在剩余空间,也不放大。

.item { flex-grow: <number>; /* default 0 */ }

如果所有项目的flex-grow属性都为1,则它们将等分剩余空间(如果有的话)。如果一个项目的flex-grow属性为2,其他项目都为1,则前者占据的剩余空间将比其他项多一倍。

4.3 flex-shrink属性

flex-shrink属性定义了项目的缩小比例,默认为1,即如果空间不足,该项目将缩小。

.item { flex-shrink: <number>; /* default 1 */ }

如果所有项目的flex-shrink属性都为1,当空间不足时,都将等比例缩小。如果一个项目的flex-shrink属性为0,其他项目都为1,则空间不足时,前者不缩小。

负值对该属性无效。

4.4 flex-basis属性

flex-basis属性定义了在分配多余空间之前,项目占据的主轴空间(main size)。浏览器根据这个属性,计算主轴是否有多余空间。它的默认值为auto,即项目的本来大小。

.item { flex-basis: <length> | auto; /* default auto */ }

它可以设为跟width或height属性一样的值(比如350px),则项目将占据固定空间。

4.5 flex属性

flex属性是flex-grow,?flex-shrink?和?flex-basis的简写,默认值为0 1 auto。后两个属性可选。

.item { flex: none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ] }

该属性有两个快捷值:auto?(1 1 auto) 和 none (0 0 auto)。

建议优先使用这个属性,而不是单独写三个分离的属性,因为浏览器会推算相关值。

4.6 align-self属性

align-self属性允许单个项目有与其他项目不一样的对齐方式,可覆盖align-items属性。默认值为auto,表示继承父元素的align-items属性,如果没有父元素,则等同于stretch。

.item { align-self: auto | flex-start | flex-end | center | baseline | stretch; }

该属性可能取6个值,除了auto,其他都与align-items属性完全一致。

如何在网页上某一个div内滚动滚动条时,禁止整个document的滚动?

lopo1983 回复了问题 • 2 人关注 • 2 个回复 • 2476 次浏览 • 2016-02-16 16:02 • 来自相关话题

css3 hover 放大圈效果

lopo1983 发表了文章 • 1 个评论 • 2144 次浏览 • 2016-01-21 10:27 • 来自相关话题

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title></title>
<meta name="description" content="">
<meta name="HandheldFriendly" content="True">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<style>
html,
body {
height: 100%;
background-color: rgb(56, 81, 188);
}

.icon {
display: inline-block;
font-size: 0px;
cursor: pointer;
margin: 60px 120px;
width: 90px;
height: 90px;
border-radius: 50%;
text-align: center;
position: relative;
z-index: 1;
color: #fff;
}

.icon-mix .icon {
background: rgba(255, 255, 255, 0.1);
-webkit-transition: -webkit-transform ease-out 0.1s, background 0.2s;
transition: transform ease-out 0.1s, background 0.2s;
}

.icon-mix .icon:after {
pointer-events: none;
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
content: '';
top: 0;
left: 0;
padding: 0;
z-index: -1;
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
opacity: 0;
-webkit-transform: scale(0.9);
transform: scale(0.9);
}

.icon-mix .icon:hover {
background: rgba(255, 255, 255, 0.05);
-webkit-transform: scale(0.93);
transform: scale(0.93);
color: #fff;
}

.icon-mix .icon:hover:after {
-webkit-animation: roundout 1.3s ease-out 75ms;
animation: roundout 1.3s ease-out 75ms;
}

@-webkit-keyframes roundout {
0% {
opacity: 0.3;
}
40% {
opacity: 0.5;
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1), 0 0 10px 10px #3851bc, 0 0 0 10px rgba(255, 255, 255, 0.5);
}
100% {
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1), 0 0 10px 10px #3851bc, 0 0 0 10px rgba(255, 255, 255, 0.5);
-webkit-transform: scale(1.5);
opacity: 0;
}
}

@keyframes roundout {
0% {
opacity: 0.3;
}
40% {
opacity: 0.5;
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1), 0 0 10px 10px #3851bc, 0 0 0 10px rgba(255, 255, 255, 0.5);
}
100% {
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1), 0 0 10px 10px #3851bc, 0 0 0 10px rgba(255, 255, 255, 0.5);
transform: scale(1.5);
opacity: 0;
}
}
</style>
</head>

<body>
<div class="icon-mix">
<a href="javascript:;" class="icon"></a>
<a href="javascript:;" class="icon"></a>
<a href="javascript:;" class="icon"></a>
</div>
</body>

</html>原本是帮一个妹纸写的效果 结果理解错误了 哈哈? 查看全部
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title></title>
<meta name="description" content="">
<meta name="HandheldFriendly" content="True">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<style>
html,
body {
height: 100%;
background-color: rgb(56, 81, 188);
}

.icon {
display: inline-block;
font-size: 0px;
cursor: pointer;
margin: 60px 120px;
width: 90px;
height: 90px;
border-radius: 50%;
text-align: center;
position: relative;
z-index: 1;
color: #fff;
}

.icon-mix .icon {
background: rgba(255, 255, 255, 0.1);
-webkit-transition: -webkit-transform ease-out 0.1s, background 0.2s;
transition: transform ease-out 0.1s, background 0.2s;
}

.icon-mix .icon:after {
pointer-events: none;
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
content: '';
top: 0;
left: 0;
padding: 0;
z-index: -1;
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
opacity: 0;
-webkit-transform: scale(0.9);
transform: scale(0.9);
}

.icon-mix .icon:hover {
background: rgba(255, 255, 255, 0.05);
-webkit-transform: scale(0.93);
transform: scale(0.93);
color: #fff;
}

.icon-mix .icon:hover:after {
-webkit-animation: roundout 1.3s ease-out 75ms;
animation: roundout 1.3s ease-out 75ms;
}

@-webkit-keyframes roundout {
0% {
opacity: 0.3;
}
40% {
opacity: 0.5;
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1), 0 0 10px 10px #3851bc, 0 0 0 10px rgba(255, 255, 255, 0.5);
}
100% {
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1), 0 0 10px 10px #3851bc, 0 0 0 10px rgba(255, 255, 255, 0.5);
-webkit-transform: scale(1.5);
opacity: 0;
}
}

@keyframes roundout {
0% {
opacity: 0.3;
}
40% {
opacity: 0.5;
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1), 0 0 10px 10px #3851bc, 0 0 0 10px rgba(255, 255, 255, 0.5);
}
100% {
box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1), 0 0 10px 10px #3851bc, 0 0 0 10px rgba(255, 255, 255, 0.5);
transform: scale(1.5);
opacity: 0;
}
}
</style>
</head>

<body>
<div class="icon-mix">
<a href="javascript:;" class="icon"></a>
<a href="javascript:;" class="icon"></a>
<a href="javascript:;" class="icon"></a>
</div>
</body>

</html>
原本是帮一个妹纸写的效果 结果理解错误了 哈哈?